@tivio/sdk-react 9.2.0-alpha.4 → 9.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +554 -316
- package/README.md.bak +554 -316
- package/dist/index.d.ts +614 -84
- package/dist/index.js +1 -1
- package/dist/sdk-react.d.ts +616 -84
- package/package.json +3 -3
package/README.md
CHANGED
@@ -4,320 +4,6 @@
|
|
4
4
|
above Tivio Studio. You can comfortably manage all you videos, settings such as application's screens and rows and also monetization
|
5
5
|
settings in the administration of Tivio Studio while having the freedom to build your own application.
|
6
6
|
|
7
|
-
## Changelog
|
8
|
-
* 9.2.0-alpha.4
|
9
|
-
* patch: expose getUser, resetPassword and signOut methods in RemoteBundleState type
|
10
|
-
* patch: more precise types for user profile fields and methods
|
11
|
-
* patch: add missing jsdocs for some User type fields
|
12
|
-
|
13
|
-
* 9.2.0-alpha.0
|
14
|
-
* minor: add renderWebPlayer method for rendering outside of React
|
15
|
-
* minor: "expose createTivio"
|
16
|
-
|
17
|
-
* 9.1.7
|
18
|
-
* patch: update remote controller component API
|
19
|
-
|
20
|
-
* 9.1.6
|
21
|
-
* minor: add remote controller
|
22
|
-
|
23
|
-
* 9.1.5
|
24
|
-
* patch: expose purchase loyalty points through types
|
25
|
-
* patch: enable setUser check
|
26
|
-
|
27
|
-
* 9.1.4
|
28
|
-
* patch: disable setUser check
|
29
|
-
* patch: rollback "add renderWebPlayer method for rendering outside of React"
|
30
|
-
* patch: rollback "expose createTivio"
|
31
|
-
|
32
|
-
* 9.1.3
|
33
|
-
* patch: add renderWebPlayer method for rendering outside of React
|
34
|
-
* patch: expose createTivio
|
35
|
-
|
36
|
-
* 9.1.4
|
37
|
-
* patch: disable setUser check
|
38
|
-
|
39
|
-
* 9.1.3
|
40
|
-
* minor: add renderWebPlayer method for rendering outside of React
|
41
|
-
* minor: expose createTivio
|
42
|
-
|
43
|
-
* 9.1.2
|
44
|
-
* patch: update PurchaseEndpointPayload type (cityName, externalId, geoPoint)
|
45
|
-
|
46
|
-
* 9.1.1
|
47
|
-
* patch: fix changelog
|
48
|
-
|
49
|
-
* 9.1.0
|
50
|
-
* patch: add gateway to Purchase type
|
51
|
-
* minor: add QerkoPaymentWebhookByApiKeyRequest to exported types
|
52
|
-
|
53
|
-
* 9.0.0
|
54
|
-
* patch: remove i18next and react-i18next from externals and dependencies
|
55
|
-
* patch: do not send react-spring to core-react-dom bundle, remove react-spring from dependencies
|
56
|
-
* patch: clean-up externals in webpack config
|
57
|
-
* patch: send only required dependencies to the bundle
|
58
|
-
* major: change purchase statuses lifecycle
|
59
|
-
* minor: add originalPurchaseId to PurchaseEndpointPayload
|
60
|
-
|
61
|
-
* 8.0.0
|
62
|
-
* major: deprecated usePurchasesWithVideos hook removed
|
63
|
-
* patch: add id to user type
|
64
|
-
* patch: add @types/react to peerDependencies
|
65
|
-
|
66
|
-
* 7.1.0
|
67
|
-
* minor: export useTvChannelHook
|
68
|
-
* patch: bump "react-i18next", "i18next" versions.
|
69
|
-
|
70
|
-
* 7.0.1
|
71
|
-
* patch: fix dependency to @tivio/common
|
72
|
-
|
73
|
-
* 7.0.0
|
74
|
-
* major: delete deprecated useWatchWithoutAdsOffer hook
|
75
|
-
* major: consolidate duplicated source types
|
76
|
-
* patch: add new properties to PlayerInterface
|
77
|
-
* patch: expose getSeekingMatrixPreviewByTime in Video interface
|
78
|
-
* major: delete deprecated useBetOffer hook
|
79
|
-
* major: rework of source types
|
80
|
-
* major: make useChannelSource deprecated
|
81
|
-
|
82
|
-
* 6.0.1
|
83
|
-
* patch: fix dependency to @tivio/common
|
84
|
-
|
85
|
-
* 6.0.0
|
86
|
-
* major: delete usePlayerEvent hook
|
87
|
-
* major: replace uri attributes in types with url
|
88
|
-
* major: delete uri attributes from types
|
89
|
-
* minor: add purchase expiration to PurchaseEndpointPayload
|
90
|
-
* minor: add optional videoId parameter to useOrganizationSubscription hook
|
91
|
-
|
92
|
-
* 5.0.2
|
93
|
-
* patch: export hook useChannelSource
|
94
|
-
|
95
|
-
* 5.0.1
|
96
|
-
* patch: move changelog
|
97
|
-
|
98
|
-
* 5.0.0
|
99
|
-
* major: upgrade to React 18, change react and react-dom peer dependencies to 17.x || 18.x
|
100
|
-
* major: fix typing for useReferralInfo, now correctly showing that `null` can be returned
|
101
|
-
* major: fix typing for `WebRowProps.onTileClick`, now correctly showing that `null` can be accepted
|
102
|
-
* minor: add analytics
|
103
|
-
* minor: add getSourceUrl function to video and tv channel types
|
104
|
-
* minor: add uri property to tv channel type
|
105
|
-
* minor: add useChannelSource to hooks
|
106
|
-
|
107
|
-
* 4.5.0
|
108
|
-
* minor: extend PurchaseEndpointPayload type with purchase previousStatus and newStatus fields
|
109
|
-
|
110
|
-
* 4.4.1
|
111
|
-
* patch: added waitForTags param in useSearch hook for videos
|
112
|
-
|
113
|
-
* 4.4.0
|
114
|
-
* minor: PrimaryButton component props type set to any for now
|
115
|
-
* patch: isPurchasableAsVoucher added to PurchasableMonetization
|
116
|
-
* patch: voucherPurchase flag added to purchase overlays
|
117
|
-
* patch: item added to MonetizationsSelectOverlayData
|
118
|
-
* minor: added hungarian language to `LangCode` enum
|
119
|
-
|
120
|
-
* 4.3.0:
|
121
|
-
* minor: add GetPurchaseInfoResponse and PurchaseEndpointPayload to exported types
|
122
|
-
* minor: support for disabling purchase of specified subscriptions (new param in useOrganizationSubscriptions hook)
|
123
|
-
* minor: more specific PurchasableMonetization type usage instead of Monetization
|
124
|
-
* minor: monetization property deleted from Video type
|
125
|
-
* minor: monetization now has originalPrice and promotion properties available
|
126
|
-
* patch: remove not used OrganizationSubscriptionsContext, **this change requires bundle 3.20.0 or newer**
|
127
|
-
|
128
|
-
* 4.2.0:
|
129
|
-
* minor: fix useSearch loading type
|
130
|
-
* patch: added italian language to `LangCode` enum
|
131
|
-
|
132
|
-
* 4.1.0
|
133
|
-
* patch: added italian language to `LangCode` enum
|
134
|
-
* minor: fixed spanish language code in `LangCode` enum (`sp` -> `es`)
|
135
|
-
* minor: other misc type changes
|
136
|
-
|
137
|
-
* 4.0.1
|
138
|
-
* patch: added setBundleVersion setter to bundle type
|
139
|
-
* patch: added setStorageManager setter to bundle type
|
140
|
-
* patch: `Purchase.isPurchased` is deprecated
|
141
|
-
* patch: fill `useSearch` field `hasNextPage` with proper value
|
142
|
-
|
143
|
-
* 4.0.0
|
144
|
-
* minor: Types cleanup
|
145
|
-
* MAJOR: Remove deprecated and unused stuff
|
146
|
-
* auth
|
147
|
-
* changePassword
|
148
|
-
* changeUserPhoto
|
149
|
-
* removeUserPhoto
|
150
|
-
* getPurchasedVodsWithInitializedVideos
|
151
|
-
* initializeUser
|
152
|
-
* createFreePurchase
|
153
|
-
* components
|
154
|
-
* videoAdBanner
|
155
|
-
* getters
|
156
|
-
* getExportedConfig
|
157
|
-
* getChannelById
|
158
|
-
* getSectionById
|
159
|
-
* getWidgetById
|
160
|
-
* hooks
|
161
|
-
* useLastVideoByWidgetId
|
162
|
-
* useScreen
|
163
|
-
* useFreePurchase
|
164
|
-
* useWidget
|
165
|
-
* useChannel
|
166
|
-
* useSection
|
167
|
-
* useVideosInSection
|
168
|
-
* useSectionsInChannel
|
169
|
-
* useChannelsInWidget
|
170
|
-
* subscriptions
|
171
|
-
* subscribeToWidget
|
172
|
-
* subscribeToChannel
|
173
|
-
* subscribeToSection
|
174
|
-
* subscribeToVideosInSection
|
175
|
-
* subscribeToSectionsInChannel
|
176
|
-
* subscribeToChannelsInWidget
|
177
|
-
* subscribeToScreen
|
178
|
-
---
|
179
|
-
_Versions <= v3.7.0 requires core-react-dom bundle < v3.0.0 (because sdk-react used some sdk API deleted in core-react-dom@4.0.0)_
|
180
|
-
|
181
|
-
* 3.7.0
|
182
|
-
* minor: purchase contains created and updated
|
183
|
-
|
184
|
-
* 3.6.3
|
185
|
-
* patch: improve README.md
|
186
|
-
|
187
|
-
* 3.6.2
|
188
|
-
* patch: Fix types
|
189
|
-
|
190
|
-
* 3.6.1
|
191
|
-
* patch: Fix README
|
192
|
-
|
193
|
-
* 3.6.0
|
194
|
-
* minor: Update types
|
195
|
-
|
196
|
-
* 3.5.2
|
197
|
-
* patch: All types are available again.
|
198
|
-
|
199
|
-
* 3.5.1
|
200
|
-
* patch: remove incorrect dependency (@tivio/types)
|
201
|
-
|
202
|
-
* 3.5.0
|
203
|
-
* minor: Types change - Video.price and Video.detailedPrice can be null
|
204
|
-
* minor: Types change - Video.cover is marked as deprecated
|
205
|
-
|
206
|
-
* 3.4.0
|
207
|
-
* minor: more precise type for errors in usePurchaseRecovery and usePurchaseRecovery
|
208
|
-
* patch: jsdocs for usePurchaseRecovery and usePurchaseRecovery
|
209
|
-
* minor: inviteCodeReset in useApplyInviteCode
|
210
|
-
* minor: Reset forgotten password
|
211
|
-
* minor: Consolidating monetization logic
|
212
|
-
* 3.3.2
|
213
|
-
* patch: Adding new optional parameters (where, orderBy) to useTaggedVideos hook
|
214
|
-
* 3.3.1
|
215
|
-
* patch: Fixed types of `setUser`
|
216
|
-
* 3.3.0
|
217
|
-
* minor: Add getPlayerCapabilities to getters.
|
218
|
-
* patch: Added option to log out via `setUser(null)`, requires @tivio/core-react-dom@2.17.9
|
219
|
-
* 3.2.5
|
220
|
-
* patch: added recovery flag to QerkoPaymentInfo type
|
221
|
-
* patch: bundle.types changes - internal.components.WebVideoScreen
|
222
|
-
* patch: types changes - add new onBack prop to WebPlayerProps
|
223
|
-
* patch: Refactor useVideo hook, now uses hook from core-react
|
224
|
-
* 3.2.4
|
225
|
-
* minor: added useApplyInviteCode
|
226
|
-
* minor: better errors from useVoucher
|
227
|
-
* 3.2.3
|
228
|
-
* minor: added usePurchaseRecovery hook
|
229
|
-
* patch: deprecated `useLastVideoByWidgetId`
|
230
|
-
* 3.2.2
|
231
|
-
* minor: useRowsInScreen, useItemsInRow, useTaggedVideos - hasNextPage and loading added to pagination
|
232
|
-
* minor: useRowsInScreen, useItemsInRow, useTaggedVideos - implementation moved to remote bundle
|
233
|
-
* patch: Fixed Tivio startup on Tizen 6
|
234
|
-
* minor: Added `forceCloudFnResolver` option
|
235
|
-
* 3.2.1
|
236
|
-
* patch: fix of @tivio/common version
|
237
|
-
* 3.2.0
|
238
|
-
* minor: Added `capabilitiesOptions` for finer configuration of device capabilities
|
239
|
-
* minor: tag names are returned in correct language (the one from tivio config); language value should be one from enum "LangCode"
|
240
|
-
* 3.1.3
|
241
|
-
* patch: Hotfix made sure disabled Tivio does not break React Native
|
242
|
-
* 3.1.2
|
243
|
-
* patch: Allow `conf` prop of `TivioProvider` to be `null` or `undefined` in order to turn off Tivio
|
244
|
-
* 3.1.1
|
245
|
-
* patch: fixed `setUser()` crash when bundle fails to load
|
246
|
-
* 3.1.0
|
247
|
-
* patch: `useAdSegment()` now returns null if no monetization is configured, ad segments are not managed in that situation
|
248
|
-
* minor: enriched `AdSegment` type from `useAdSegment()`
|
249
|
-
* minor: Added `setUser()` function for login and logout
|
250
|
-
* 3.0.0
|
251
|
-
* minor: Added hook `useWatchWithoutAdsOffer` to trigger purchase dialog to "watch without ads", if available
|
252
|
-
* patch: fix peerDependency declaration for react, react-dom
|
253
|
-
* major: TivioProvider requires deviceCapabilities
|
254
|
-
* major: TivioProvider requires currency
|
255
|
-
* minor: add voucher support (see usePurchaseSubscription and useTransactionPayment hooks)
|
256
|
-
* minor: device limit support
|
257
|
-
* minor: drm (Widevine, PlayReady) support
|
258
|
-
* minor: watermarking support
|
259
|
-
* minor: add useSearch hook
|
260
|
-
* patch: price on video is 0 when purchased
|
261
|
-
* 2.4.2
|
262
|
-
* patch: added back changelog
|
263
|
-
* 2.4.1
|
264
|
-
* patch: improved doc about player wrapper
|
265
|
-
* 2.4.0
|
266
|
-
* patch: improved Player wrapper types
|
267
|
-
* minor: added Tivio DOM events `tivio_key_input_handling_change`, `tivio_context_switch` and `tivio_request_goto`
|
268
|
-
* patch: added support for remote code on browsers that do not implement [indexedDB API](https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API)
|
269
|
-
* patch: added support for browsers that do not implement [indexedDB API](https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API)
|
270
|
-
* 2.3.4
|
271
|
-
* patch: fix of usePurchaseSubscription not reactive
|
272
|
-
* 2.3.3
|
273
|
-
* patch: fix of useUser not updating
|
274
|
-
* 2.3.2
|
275
|
-
* patch: next app doesn't fail anymore due to "self is not defined"
|
276
|
-
* 2.3.1
|
277
|
-
* patch: fix of @tivio/common dependency
|
278
|
-
* 2.3.0
|
279
|
-
* minor: add useTaggedVideos that allows to fetch videos with given tags
|
280
|
-
* minor: add option to fetch tags (on hook useItemsInRow), useVideo always fetching videos tags
|
281
|
-
* 2.2.1
|
282
|
-
* patch: disable Sentry when no config is supplied to `TivioProvider`
|
283
|
-
* 2.2.0
|
284
|
-
* patch: reduced bundle size
|
285
|
-
* minor: disable Sentry when no config is supplied to `TivioProvider` or when Tivio is disabled `{ enable: false }`, or when Sentry is disabled via config `{ enableSentry: false }`
|
286
|
-
* 2.1.5
|
287
|
-
* patch fix of `useVideosInSection` hook (fetching video's monetizations)
|
288
|
-
* 2.1.4
|
289
|
-
* patch: fix re-rendering of `useAd` during non-skippable ads (requires core-react-dom@2.1.9)
|
290
|
-
* 2.1.3
|
291
|
-
* patch: fix changelog
|
292
|
-
* 2.1.2
|
293
|
-
* patch: Fixed exported types
|
294
|
-
* 2.1.1
|
295
|
-
* patch: TivioWidget now correctly reports `false` via `onEnabled` callback when in invalid internal state
|
296
|
-
* 2.1.0
|
297
|
-
* patch: fix of useItemsInRow hook
|
298
|
-
* patch: fix of useScreen hook
|
299
|
-
* add: useRowsInScreen hook
|
300
|
-
* 2.0.3
|
301
|
-
* patch: fix of useItemsInRow hook
|
302
|
-
* 2.0.2
|
303
|
-
* patch: screen and row IDs fixed
|
304
|
-
* `TivioBundle.subscriptions.subscribeToItemsInRow` now accepts user-defined ID via studio.tiv.io
|
305
|
-
* `TivioBundle.subscriptions.subscribeToScreen` now accepts user-defined ID via studio.tiv.io
|
306
|
-
* `Screen` and `Row` types returned by `useScreen()` return their user-defined IDs (`.id`) correctly
|
307
|
-
* 2.0.1
|
308
|
-
* no changes
|
309
|
-
* 2.0.0
|
310
|
-
* major: video.channelId can now be `string | null` used to be `string`
|
311
|
-
* minor: added data API and hooks for screens (screens, rows of screen and row items)
|
312
|
-
* hooks: `useScreen()`, `useItemsInRow()`
|
313
|
-
* api: `TivioBundle.subscriptions.subscribeToScreen`, `TivioBundle.subscriptions.subscribeToItemsInRow`
|
314
|
-
* 1.3.6
|
315
|
-
* ?
|
316
|
-
* 1.3.5
|
317
|
-
* minor: added WebPlayer props (canReplay, showMarkers, customShortcuts, enableKeyboardShortcuts, source.poster)
|
318
|
-
* 1.3.4
|
319
|
-
* ...
|
320
|
-
|
321
7
|
## Installation
|
322
8
|
|
323
9
|
Install @tivio/sdk-react along with its peer dependencies
|
@@ -366,6 +52,301 @@ await setUser('userId', { token: 'xxx'})
|
|
366
52
|
await setUser(null)
|
367
53
|
```
|
368
54
|
|
55
|
+
### Create user with email and password
|
56
|
+
|
57
|
+
Returns user's firebase uid or null if error occurs
|
58
|
+
|
59
|
+
```typescript
|
60
|
+
tivio.createUserWithEmailAndPassword(email: string, password: string, username: string, phoneNumber?: string | undefined): Promise<string | null>
|
61
|
+
```
|
62
|
+
**Example**
|
63
|
+
```typescript
|
64
|
+
await tivio.createUserWithEmailAndPassword('test@example.com', 'password', 'Fist & Last Name', '+420777123456')
|
65
|
+
```
|
66
|
+
|
67
|
+
### Sign in with email and password
|
68
|
+
|
69
|
+
Returns user's firebase uid or null if error occurs
|
70
|
+
|
71
|
+
```typescript
|
72
|
+
tivio.signInWithEmailAndPassword(email: string, password: string): Promise<string | null>
|
73
|
+
```
|
74
|
+
**Example**
|
75
|
+
```typescript
|
76
|
+
await tivio.signInWithEmailAndPassword('test@example.com', 'password')
|
77
|
+
```
|
78
|
+
|
79
|
+
### Sign out
|
80
|
+
|
81
|
+
```typescript
|
82
|
+
tivio.signOut(): Promise<void>
|
83
|
+
```
|
84
|
+
|
85
|
+
### Reset password
|
86
|
+
|
87
|
+
Send email with password reset link to the user with given email address
|
88
|
+
|
89
|
+
```typescript
|
90
|
+
tivio.resetPassword(email: string): Promise<void>
|
91
|
+
```
|
92
|
+
|
93
|
+
## User entity
|
94
|
+
|
95
|
+
### Get user
|
96
|
+
|
97
|
+
Returns user object or null if user is not authenticated
|
98
|
+
|
99
|
+
```typescript
|
100
|
+
tivio.getUser(): Promise<User | null>
|
101
|
+
```
|
102
|
+
|
103
|
+
### Essential Properties
|
104
|
+
|
105
|
+
#### Basic Information
|
106
|
+
- `id: string` - Unique Tivio user ID
|
107
|
+
- `email?: string` - Email address
|
108
|
+
- `name?: string` - Display name - could be nickname, first name and last name, etc.
|
109
|
+
|
110
|
+
#### Authentication Status
|
111
|
+
- `isSignedIn: boolean` - Whether the user is currently signed in
|
112
|
+
- `isReady: boolean` - Whether user data is fully loaded
|
113
|
+
- `isAnonymous: boolean` - Whether this is an anonymous user
|
114
|
+
|
115
|
+
#### Content & Preferences
|
116
|
+
- `purchases: Purchase[]` - Active purchases (excluding vouchers)
|
117
|
+
|
118
|
+
#### User Profiles
|
119
|
+
- `profiles: UserProfile[]` - Available user profiles (e.g. multiple people can use the same user account with different preferences)
|
120
|
+
- `activeUserProfileId: string | null` - Currently active profile
|
121
|
+
|
122
|
+
### Essential Methods
|
123
|
+
|
124
|
+
#### Authentication
|
125
|
+
```typescript
|
126
|
+
changePassword(oldPassword: string, newPassword: string): Promise<void>
|
127
|
+
```
|
128
|
+
|
129
|
+
#### Profile Management
|
130
|
+
|
131
|
+
#### Create user profile
|
132
|
+
|
133
|
+
```typescript
|
134
|
+
interface CreateUserProfileRequest {
|
135
|
+
/**
|
136
|
+
* Profile name - typically first name and last name, but users can fill in whatever they want.
|
137
|
+
*/
|
138
|
+
name: string
|
139
|
+
/**
|
140
|
+
* Filled in values for user profile survey. See {@link OrganizationDocument} its configuration.
|
141
|
+
*/
|
142
|
+
survey?: ProfileSurvey
|
143
|
+
}
|
144
|
+
interface ProfileSurvey {
|
145
|
+
gender?: Translation
|
146
|
+
age?: AgeRange
|
147
|
+
}
|
148
|
+
interface AgeRange {
|
149
|
+
from: number
|
150
|
+
/**
|
151
|
+
* If not set, we assume the range is not closed and {@property to} is set to infinity
|
152
|
+
* (there are no values to represent {@link Infinity} in firestore, so we use undefined instead).
|
153
|
+
*/
|
154
|
+
to?: number
|
155
|
+
/**
|
156
|
+
* If set, we assume that this is a profile for kids only (e.g. 0-12).
|
157
|
+
* This value can only be `true` or not specified (undefined).
|
158
|
+
*/
|
159
|
+
kidsOnly?: true
|
160
|
+
}
|
161
|
+
createUserProfile(request: CreateUserProfileRequest): Promise<void>
|
162
|
+
```
|
163
|
+
**Example**
|
164
|
+
```typescript
|
165
|
+
await user.createUserProfile({
|
166
|
+
name: 'John Doe',
|
167
|
+
survey: {
|
168
|
+
gender: {
|
169
|
+
cs: "Žena",
|
170
|
+
en: "Female",
|
171
|
+
sk: "Žena"
|
172
|
+
},
|
173
|
+
age: {
|
174
|
+
from: 18,
|
175
|
+
to: 24
|
176
|
+
}
|
177
|
+
}
|
178
|
+
})
|
179
|
+
```
|
180
|
+
|
181
|
+
#### Set active user profile
|
182
|
+
|
183
|
+
```typescript
|
184
|
+
user.setActiveUserProfileId(profileId: string): void
|
185
|
+
|
186
|
+
#### Delete user profile
|
187
|
+
|
188
|
+
```typescript
|
189
|
+
user.deleteUserProfile(profileId: string): Promise<void>
|
190
|
+
```
|
191
|
+
```
|
192
|
+
|
193
|
+
## Content
|
194
|
+
|
195
|
+
### Assets
|
196
|
+
|
197
|
+
In order to obtain assets (images) from a Video or Tag, you can use these methods:
|
198
|
+
|
199
|
+
#### Video or Tag
|
200
|
+
- `video.cover` - cover image (landscape)
|
201
|
+
- `video.banner` - banner image
|
202
|
+
- `video.circled` - circled image
|
203
|
+
- `video.detailBanner` - detail banner image (landscape)
|
204
|
+
- `video.portrait` - portrait image (portrait)
|
205
|
+
|
206
|
+
#### Tag only
|
207
|
+
- `tag.bannerMobile` - banner image mobile
|
208
|
+
|
209
|
+
__All of the assets fallback to type cover or empty string if cover is not available__
|
210
|
+
|
211
|
+
### Get content based on user profile
|
212
|
+
|
213
|
+
```typescript
|
214
|
+
interface GetUserProfileDataOptions {
|
215
|
+
/**
|
216
|
+
* If true, the data will be returned for all user profiles.
|
217
|
+
* If false, the data will be returned only for the active user profile.
|
218
|
+
*/
|
219
|
+
ignoreActiveUserProfile?: boolean
|
220
|
+
}
|
221
|
+
|
222
|
+
getFavorites(options?: GetUserProfileDataOptions): Promise<FavoriteWithData[]>
|
223
|
+
getWatchPositions(options?: GetUserProfileDataOptions): Promise<WatchPositionWithData[]>
|
224
|
+
getWatchHistory(options?: GetUserProfileDataOptions): Promise<WatchPositionWithData[]>
|
225
|
+
```
|
226
|
+
|
227
|
+
### Get user favorites
|
228
|
+
|
229
|
+
```typescript
|
230
|
+
interface FavoriteWithData {
|
231
|
+
content: Video | Tag
|
232
|
+
type: 'video' | 'tag' // Filtering by this type will set the content type to be Video or Tag
|
233
|
+
profileId?: string
|
234
|
+
}
|
235
|
+
|
236
|
+
getFavorites(options?: GetUserProfileDataOptions): Promise<FavoriteWithData[]>
|
237
|
+
```
|
238
|
+
**Example**
|
239
|
+
```typescript
|
240
|
+
const favorites = await tivio.getFavorites()
|
241
|
+
favorites.forEach(favorite => {
|
242
|
+
console.log({
|
243
|
+
name: favorite.name,
|
244
|
+
cover: favorite.cover, // cover image (landscape)
|
245
|
+
portrait: favorite.portrait, // portrait image (portrait)
|
246
|
+
})
|
247
|
+
})
|
248
|
+
```
|
249
|
+
|
250
|
+
### Get user watch positions
|
251
|
+
|
252
|
+
```typescript
|
253
|
+
interface WatchPositionWithData {
|
254
|
+
position: number
|
255
|
+
video: Video
|
256
|
+
tag?: Tag
|
257
|
+
episodeNumber?: number
|
258
|
+
seasonNumber?: number
|
259
|
+
videoDuration?: number
|
260
|
+
}
|
261
|
+
|
262
|
+
getWatchPositions(options?: GetUserProfileDataOptions): Promise<WatchPositionWithData[]>
|
263
|
+
```
|
264
|
+
**Example**
|
265
|
+
```typescript
|
266
|
+
const watchPositions = await tivio.getWatchPositions()
|
267
|
+
watchPositions.forEach(watchPosition => {
|
268
|
+
console.log({
|
269
|
+
position: watchPosition.position, // watch position in milliseconds
|
270
|
+
videoName: watchPosition.video.name,
|
271
|
+
videoCover: watchPosition.video.cover,
|
272
|
+
tagName: watchPosition.tag?.name, // optional tag for series
|
273
|
+
episodeNumber: watchPosition.episodeNumber, // optional episode number
|
274
|
+
seasonNumber: watchPosition.seasonNumber, // optional season number
|
275
|
+
videoDuration: watchPosition.videoDuration, // optional video duration
|
276
|
+
})
|
277
|
+
})
|
278
|
+
```
|
279
|
+
|
280
|
+
### Get user watch history
|
281
|
+
|
282
|
+
```typescript
|
283
|
+
getWatchHistory(options?: GetUserProfileDataOptions): Promise<WatchPositionWithData[]>
|
284
|
+
```
|
285
|
+
**Example**
|
286
|
+
```typescript
|
287
|
+
const watchHistory = await tivio.getWatchHistory()
|
288
|
+
watchHistory.forEach(watchPosition => {
|
289
|
+
console.log({
|
290
|
+
position: watchPosition.position, // watch position in milliseconds
|
291
|
+
videoName: watchPosition.video.name,
|
292
|
+
videoCover: watchPosition.video.cover,
|
293
|
+
tagName: watchPosition.tag?.name, // optional tag for series
|
294
|
+
episodeNumber: watchPosition.episodeNumber, // optional episode number
|
295
|
+
seasonNumber: watchPosition.seasonNumber, // optional season number
|
296
|
+
videoDuration: watchPosition.videoDuration, // optional video duration
|
297
|
+
})
|
298
|
+
})
|
299
|
+
```
|
300
|
+
|
301
|
+
### Add to/remove from favorites
|
302
|
+
|
303
|
+
Simply call addToFavorites or removeFromFavorites on the Video or Tag.
|
304
|
+
```typescript
|
305
|
+
const video = await tivio.getVideoById('videoId')
|
306
|
+
await video.addToFavorites()
|
307
|
+
await video.removeFromFavorites()
|
308
|
+
|
309
|
+
const tag = await tivio.getTagById('tagId')
|
310
|
+
await tag.addToFavorites()
|
311
|
+
await tag.removeFromFavorites()
|
312
|
+
|
313
|
+
// Remove a favorite from favorites
|
314
|
+
const favorites = await tivio.getUser()?.favorites
|
315
|
+
favorites[0]?.removeFromFavorites()
|
316
|
+
```
|
317
|
+
|
318
|
+
> Note: When user saves favorite without profileId, it will only be shown if the app doesn't have any active user profile.
|
319
|
+
|
320
|
+
### Get screen by ID
|
321
|
+
|
322
|
+
```typescript
|
323
|
+
getScreenById(screenId: string): Promise<Screen | null>
|
324
|
+
```
|
325
|
+
|
326
|
+
### Get row by ID
|
327
|
+
|
328
|
+
```typescript
|
329
|
+
getRowById(rowId: string): Promise<Row | null>
|
330
|
+
```
|
331
|
+
|
332
|
+
### Get video by ID
|
333
|
+
|
334
|
+
```typescript
|
335
|
+
getVideoById(videoId: string): Promise<Video | null>
|
336
|
+
```
|
337
|
+
|
338
|
+
### Get tag by ID
|
339
|
+
|
340
|
+
```typescript
|
341
|
+
getTagById(tagId: string): Promise<Tag | null>
|
342
|
+
```
|
343
|
+
|
344
|
+
### Get TV Channel by ID
|
345
|
+
|
346
|
+
```typescript
|
347
|
+
getTvChannelById(tvChannelId: string): Promise<TvChannel | null>
|
348
|
+
```
|
349
|
+
|
369
350
|
## Player
|
370
351
|
|
371
352
|
You can choose whether you will use complete player component provided by Tivio or you will wrap your existing player
|
@@ -508,9 +489,266 @@ function CustomPlayer() {
|
|
508
489
|
}
|
509
490
|
```
|
510
491
|
|
511
|
-
##
|
492
|
+
## JavaScript Methods for Rendering Players
|
493
|
+
|
494
|
+
### renderWebPlayer
|
495
|
+
|
496
|
+
The `renderWebPlayer` method allows you to render a Tivio player outside of React components. This is useful for scenarios where you need to integrate the player into non-React environments.
|
497
|
+
|
498
|
+
The method is asynchronous and returns a VideoController instance that provides comprehensive control over playback.
|
499
|
+
|
500
|
+
```typescript
|
501
|
+
import { renderWebPlayer } from '@tivio/sdk-react'
|
502
|
+
|
503
|
+
// Example usage
|
504
|
+
const videoController = await renderWebPlayer(
|
505
|
+
document.getElementById('video-player'),
|
506
|
+
{
|
507
|
+
id: 'player-main',
|
508
|
+
source: 'videos/ID',
|
509
|
+
}
|
510
|
+
)
|
511
|
+
|
512
|
+
// Control playback
|
513
|
+
videoController.play()
|
514
|
+
videoController.pause()
|
515
|
+
videoController.togglePause()
|
516
|
+
|
517
|
+
// Seeking
|
518
|
+
videoController.seekToAbsolutePosition(30000) // Seek to 30 seconds
|
519
|
+
videoController.seekBy(5000) // Seek forward by 5 seconds
|
520
|
+
videoController.seekToPercent(50) // Seek to 50% of video
|
521
|
+
videoController.seekToLive() // Seek to live position (for live streams)
|
522
|
+
|
523
|
+
// Volume control
|
524
|
+
videoController.changeVolume(0.8) // Set volume to 80%
|
525
|
+
videoController.volumeUp() // Increase volume by 5%
|
526
|
+
videoController.volumeDown() // Decrease volume by 5%
|
527
|
+
videoController.mute()
|
528
|
+
videoController.unmute()
|
529
|
+
videoController.toggleMute()
|
530
|
+
|
531
|
+
// Get current source
|
532
|
+
console.log('Current source:', videoController.currentSource)
|
533
|
+
|
534
|
+
// Change source
|
535
|
+
videoController.setSource('videos/newVideoId') // Change to a different video
|
536
|
+
videoController.setSource('tvChannels/channelId') // Change to a TV channel
|
537
|
+
videoController.setSource(null) // Stop playback
|
538
|
+
|
539
|
+
// Event handling
|
540
|
+
videoController.addEventListener('video_unit_ended', () => {
|
541
|
+
console.log('Video playback ended')
|
542
|
+
})
|
543
|
+
|
544
|
+
videoController.addEventListener('timeupdate', (currentTime) => {
|
545
|
+
console.log('Current time:', currentTime)
|
546
|
+
})
|
547
|
+
|
548
|
+
// Cleanup
|
549
|
+
videoController.destroy()
|
550
|
+
```
|
551
|
+
|
552
|
+
#### VideoController Methods
|
553
|
+
|
554
|
+
The VideoController returned by `renderWebPlayer` provides the following methods:
|
555
|
+
|
556
|
+
**Playback Control:**
|
557
|
+
- `play()` - Resume playback from paused state
|
558
|
+
- `pause()` - Pause the current playback
|
559
|
+
- `togglePause()` - Toggle between play and pause states
|
560
|
+
- `replay()` - Replay the current video from the beginning
|
561
|
+
- `retry()` - Retry playback if it failed to start
|
562
|
+
|
563
|
+
**Seeking:**
|
564
|
+
- `seekToAbsolutePosition(ms: number)` - Seek to absolute position in milliseconds
|
565
|
+
- `seekBy(ms: number)` - Seek relative to current position
|
566
|
+
- `seekToPercent(percentage: number)` - Seek to percentage of video duration
|
567
|
+
- `seekToLive()` - Seek to live position (for live streams)
|
568
|
+
|
569
|
+
**Volume Control:**
|
570
|
+
- `changeVolume(value: number)` - Set volume (0-1)
|
571
|
+
- `volumeUp()` - Increase volume by 5%
|
572
|
+
- `volumeDown()` - Decrease volume by 5%
|
573
|
+
- `mute()` - Mute audio
|
574
|
+
- `unmute()` - Unmute audio
|
575
|
+
- `toggleMute()` - Toggle mute state
|
512
576
|
|
513
|
-
|
577
|
+
**Source Management:**
|
578
|
+
- `setSource(source: WebPlayerProps['source'])` - Change the current source to a new one (updates player props)
|
579
|
+
- `currentSource` - Currently playing source or null if no source is loaded
|
580
|
+
|
581
|
+
#### Source Types
|
582
|
+
|
583
|
+
The Tivio player supports different types of sources:
|
584
|
+
|
585
|
+
**VOD_EXTERNAL** - External video-on-demand content from third-party URLs
|
586
|
+
- Used for playing videos that are hosted outside of Tivio's infrastructure
|
587
|
+
- Supports various streaming protocols (HLS, DASH, MP4)
|
588
|
+
- Example usage:
|
589
|
+
```typescript
|
590
|
+
const externalSource = {
|
591
|
+
type: SourceType.VOD_EXTERNAL,
|
592
|
+
url: 'https://example.com/video.m3u8',
|
593
|
+
sourcePlayMode: SourcePlayMode.ON_DEMAND,
|
594
|
+
poster: 'https://example.com/poster.jpg',
|
595
|
+
name: 'External Video',
|
596
|
+
autoplay: false,
|
597
|
+
continuePositionMs: 10000, // Start at 10 seconds (optional)
|
598
|
+
}
|
599
|
+
```
|
600
|
+
|
601
|
+
#### Source Play Modes
|
602
|
+
|
603
|
+
The `sourcePlayMode` property determines how the content is played:
|
604
|
+
|
605
|
+
- **ON_DEMAND** - Standard video playback with full seeking capabilities
|
606
|
+
- **LIVE** - Live stream mode with no seeking
|
607
|
+
- **HYBRID** - Combines LIVE with seeking
|
608
|
+
|
609
|
+
#### Using setSource with VideoController
|
610
|
+
|
611
|
+
The `setSource` method allows you to dynamically change what's playing:
|
612
|
+
|
613
|
+
```typescript
|
614
|
+
// Change to a different video
|
615
|
+
videoController.setSource('videos/newVideoId')
|
616
|
+
|
617
|
+
// Change to an external video
|
618
|
+
videoController.setSource({
|
619
|
+
type: SourceType.VOD_EXTERNAL,
|
620
|
+
url: 'https://example.com/video.mpd',
|
621
|
+
sourcePlayMode: SourcePlayMode.ON_DEMAND,
|
622
|
+
name: 'External Video'
|
623
|
+
})
|
624
|
+
|
625
|
+
// Change to a TV channel
|
626
|
+
videoController.setSource('tvChannels/channelId')
|
627
|
+
|
628
|
+
// Stop playback
|
629
|
+
videoController.setSource(null)
|
630
|
+
```
|
631
|
+
|
632
|
+
The `setSource` method is particularly useful for:
|
633
|
+
- Play next
|
634
|
+
- Implementing playlists
|
635
|
+
- Dynamic content loading
|
636
|
+
|
637
|
+
**Event Handling:**
|
638
|
+
- `addEventListener(event: string, callback: (value: T) => void)` - Add event listener
|
639
|
+
- `removeEventListener(event: string, callback: (value: T) => void)` - Remove event listener
|
640
|
+
|
641
|
+
**Utility:**
|
642
|
+
- `destroy()` - Destroy player and clean up resources
|
643
|
+
|
644
|
+
#### Playback Events
|
645
|
+
|
646
|
+
The VideoController emits various events that you can listen to:
|
647
|
+
|
648
|
+
```typescript
|
649
|
+
// Video state changes
|
650
|
+
videoController.addEventListener('statechange', (state) => {
|
651
|
+
console.log('Player state:', state) // 'playing', 'paused', 'idle'
|
652
|
+
})
|
653
|
+
|
654
|
+
// Time updates
|
655
|
+
videoController.addEventListener('timeupdate', (currentTime) => {
|
656
|
+
console.log('Current time:', currentTime)
|
657
|
+
})
|
658
|
+
|
659
|
+
// Video ended
|
660
|
+
videoController.addEventListener('video_unit_ended', () => {
|
661
|
+
console.log('Video playback ended')
|
662
|
+
})
|
663
|
+
|
664
|
+
// Duration changes
|
665
|
+
videoController.addEventListener('durationchange', (duration) => {
|
666
|
+
console.log('Video duration:', duration)
|
667
|
+
})
|
668
|
+
|
669
|
+
// Volume changes
|
670
|
+
videoController.addEventListener('volumechange', ({ muted, volume }: { muted: boolean, volume: number }) => {
|
671
|
+
console.log('Volume changed:', { muted, volume })
|
672
|
+
})
|
673
|
+
|
674
|
+
// Buffering state
|
675
|
+
videoController.addEventListener('bufferingchange', (isBuffering) => {
|
676
|
+
console.log('Buffering:', isBuffering)
|
677
|
+
})
|
678
|
+
|
679
|
+
// Errors
|
680
|
+
videoController.addEventListener('error', (error) => {
|
681
|
+
console.error('Playback error:', error)
|
682
|
+
})
|
683
|
+
```
|
684
|
+
|
685
|
+
## WebPlayerProps
|
686
|
+
|
687
|
+
The `WebPlayerProps` interface defines the properties that can be passed to the Tivio WebPlayer component. Here's a comprehensive overview of available properties:
|
688
|
+
|
689
|
+
### Required Properties
|
690
|
+
|
691
|
+
- **`id`** (string): Unique identifier for the player instance. This is required and must be unique across your application.
|
692
|
+
|
693
|
+
### Source Properties
|
694
|
+
|
695
|
+
- **`source`** (optional): The video or channel source to play. Can be:
|
696
|
+
- `VideoPath` (string): Path to a video (e.g., "videos/VIDEO_ID")
|
697
|
+
- `ChannelPath` (string): Path to a TV channel (e.g., "tvChannels/CHANNEL_ID")
|
698
|
+
- `SourceParams` (object): Complex source parameters
|
699
|
+
- `null`: No source (player will be idle)
|
700
|
+
|
701
|
+
### Callback Properties
|
702
|
+
|
703
|
+
- **`onEnded`** (optional): Callback function called when video playback ends
|
704
|
+
- **`onProgress`** (optional): Callback function for video progress events
|
705
|
+
|
706
|
+
### Layout Properties
|
707
|
+
|
708
|
+
- **`className`** (optional): CSS class name for the player container
|
709
|
+
- **`isSameSizeAsParent`** (optional): If `true`, the player will inherit the width and height of its parent element
|
710
|
+
|
711
|
+
### Playback Control Properties
|
712
|
+
|
713
|
+
- **`autoplay`** (optional, default: `false`): Whether to start playback automatically. Note that autoplay may be blocked by browsers before user interaction
|
714
|
+
- **`canReplay`** (optional, default: `true`): Whether to show replay functionality
|
715
|
+
- **`doNotSaveWatchPosition`** (optional): If `true`, the player won't save the watch position
|
716
|
+
- **`disablePlayNext`** (optional): If `true`, the player won't automatically play the next video when current video ends
|
717
|
+
|
718
|
+
### Visual Properties
|
719
|
+
|
720
|
+
- **`showMarkers`** (optional, default: `false`): Whether to show video markers
|
721
|
+
- **`markerColor`** (optional): Color for video markers (CSS color value)
|
722
|
+
- **`showTvStreamType`** (optional): Whether to show TV stream type indicator
|
723
|
+
- **`showCookiesSettings`** (optional): Whether to show cookies settings
|
724
|
+
- **`showOsd`** (optional, default: `true`): Whether to show the On-Screen Display (OSD)
|
725
|
+
- **`showBufferingSpinner`** (optional, default: `true`): Whether to show buffering spinner
|
726
|
+
|
727
|
+
### Audio Properties
|
728
|
+
|
729
|
+
- **`isMutedByDefault`** (optional): If `true`, the player starts muted but can be unmuted
|
730
|
+
|
731
|
+
### Keyboard Shortcuts Properties
|
732
|
+
|
733
|
+
- **`enableKeyboardShortcuts`** (optional, default: `true`): Whether to enable keyboard shortcuts
|
734
|
+
- **`customShortcuts`** (optional): Custom keyboard shortcuts configuration:
|
735
|
+
```typescript
|
736
|
+
{
|
737
|
+
toggleFullscreen: number[], // Array of key codes
|
738
|
+
togglePause: number[],
|
739
|
+
toggleMute: number[],
|
740
|
+
jumpForward: number[],
|
741
|
+
jumpBack: number[],
|
742
|
+
volumeUp: number[],
|
743
|
+
volumeDown: number[]
|
744
|
+
}
|
745
|
+
```
|
746
|
+
|
747
|
+
### Ad Block Properties
|
748
|
+
|
749
|
+
- **`checkAdBlock`** (optional, default: `false`): Whether to check for ad blockers and show warnings
|
750
|
+
|
751
|
+
## Data hooks
|
514
752
|
Gets information about current user.
|
515
753
|
|
516
754
|
```ts
|