@tivio/sdk-react 4.5.0 → 5.0.0
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +0 -217
- package/changelog.md +224 -0
- package/dist/index.d.ts +312 -41
- package/dist/index.js +1 -1
- package/dist/sdk-react.d.ts +312 -41
- package/package.json +22 -19
- package/README.md.bak +0 -486
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@tivio/sdk-react",
|
3
|
-
"version": "
|
3
|
+
"version": "5.0.0",
|
4
4
|
"main": "dist/index.js",
|
5
5
|
"typings": "dist/index.d.ts",
|
6
6
|
"source": "src/index.ts",
|
@@ -13,24 +13,27 @@
|
|
13
13
|
"build:dev": "cat ./.env.dev > ./.env && yarn build --config=webpack.config.dev.js && yarn typesRollup",
|
14
14
|
"build:prod": "cat ./.env.prod > ./.env && yarn build --config=webpack.config.prod.js && yarn typesRollup",
|
15
15
|
"build:local": "bash ./scripts/build_with_local_bundle.sh && yarn typesRollup",
|
16
|
+
"release": "ts-node ./scripts/release.ts -p=sdk-react",
|
17
|
+
"release:patch": "yarn release -r=patch",
|
18
|
+
"release:minor": "yarn release -r=minor",
|
19
|
+
"release:major": "yarn release -r=major",
|
16
20
|
"start": "yarn ts-node ./scripts/start.ts",
|
17
21
|
"test": "jest --config=./jest.config.js --coverage",
|
18
22
|
"clean": "rm -rf dist",
|
19
23
|
"prepublishOnly": "yarn && yarn build:prod && yarn ts-node ./scripts/prepublish.ts",
|
20
24
|
"postpublish": "yarn ts-node ./scripts/postpublish.ts",
|
21
25
|
"publish:alpha": "npm publish --tag alpha",
|
22
|
-
"check:cycles": "npx madge --circular src/**/*",
|
23
26
|
"typesRollup": "yarn ts-node ./scripts/typesRollup.ts"
|
24
27
|
},
|
25
28
|
"peerDependencies": {
|
26
|
-
"react": "
|
27
|
-
"react-dom": "
|
29
|
+
"react": "17.x || 18.x",
|
30
|
+
"react-dom": "17.x || 18.x"
|
28
31
|
},
|
29
32
|
"dependencies": {
|
30
33
|
"@material-ui/core": "^4.11.2",
|
31
34
|
"@material-ui/icons": "^4.11.2",
|
32
35
|
"@sentry/browser": "^6.1.0",
|
33
|
-
"@tivio/common": "
|
36
|
+
"@tivio/common": "*",
|
34
37
|
"dayjs": "^1.11.0",
|
35
38
|
"es7-object-polyfill": "^1.0.1",
|
36
39
|
"firebase": "8.10.1",
|
@@ -39,7 +42,7 @@
|
|
39
42
|
"mobx": "^6.0.4",
|
40
43
|
"mobx-react": "^7.1.0",
|
41
44
|
"react-i18next": "^9.0.10",
|
42
|
-
"react-router-dom": "^5.
|
45
|
+
"react-router-dom": "^5.3.4",
|
43
46
|
"react-spring": "^9.2.4",
|
44
47
|
"react-virtualized": "^9.22.3",
|
45
48
|
"styled-components": "^5.2.1",
|
@@ -53,30 +56,30 @@
|
|
53
56
|
"@testing-library/react-hooks": "^5.0.3",
|
54
57
|
"@testing-library/user-event": "^12.1.10",
|
55
58
|
"@tivio/types": "*",
|
56
|
-
"@types/jest": "^26.0.
|
59
|
+
"@types/jest": "^26.0.24",
|
57
60
|
"@types/node": "^12.0.0",
|
58
61
|
"@types/node-fetch": "^2.5.8",
|
59
|
-
"@types/react": "^
|
60
|
-
"@types/react-dom": "^
|
62
|
+
"@types/react": "^18.0.28",
|
63
|
+
"@types/react-dom": "^18.0.11",
|
61
64
|
"@types/react-router-dom": "^5.1.6",
|
62
|
-
"@types/react-virtualized": "^9.21.
|
65
|
+
"@types/react-virtualized": "^9.21.21",
|
63
66
|
"@types/styled-components": "^5.1.7",
|
64
|
-
"@typescript-eslint/eslint-plugin": "^
|
65
|
-
"@typescript-eslint/parser": "^
|
67
|
+
"@typescript-eslint/eslint-plugin": "^5.30.5",
|
68
|
+
"@typescript-eslint/parser": "^5.30.5",
|
69
|
+
"circular-dependency-plugin": "^5.2.2",
|
66
70
|
"dotenv": "^9.0.0",
|
67
71
|
"eslint": "^7.19.0",
|
68
72
|
"fork-ts-checker-webpack-plugin": "^7.0.0",
|
69
|
-
"jest": "^
|
70
|
-
"jest-cli": "^26.6.
|
73
|
+
"jest": "^26.6.0",
|
74
|
+
"jest-cli": "^26.6.0",
|
71
75
|
"jest-fetch-mock": "^3.0.3",
|
72
|
-
"madge": "^5.0.1",
|
73
76
|
"node-fetch": "^2.6.1",
|
74
|
-
"react": "^
|
75
|
-
"react-dom": "^
|
77
|
+
"react": "^18.2.0",
|
78
|
+
"react-dom": "^18.2.0",
|
76
79
|
"stream-browserify": "^3.0.0",
|
77
80
|
"timers-browserify": "^2.0.12",
|
78
|
-
"ts-jest": "^26.
|
79
|
-
"typescript": "^4.
|
81
|
+
"ts-jest": "^26.5.6",
|
82
|
+
"typescript": "^4.9.4",
|
80
83
|
"web-vitals": "^1.0.1",
|
81
84
|
"yargs": "17"
|
82
85
|
}
|
package/README.md.bak
DELETED
@@ -1,486 +0,0 @@
|
|
1
|
-
# @tivio/sdk-react
|
2
|
-
|
3
|
-
@tivio/sdk-react provides everything which is necessary (components, data hooks etc.) to build a custom React application
|
4
|
-
above Tivio Studio. You can comfortably manage all you videos, settings such as application's screens and rows and also monetization
|
5
|
-
settings in the administration of Tivio Studio while having the freedom to build your own application.
|
6
|
-
|
7
|
-
## Changelog
|
8
|
-
|
9
|
-
* v4.5.0
|
10
|
-
* minor: extend PurchaseEndpointPayload type with purchase previousStatus and newStatus fields
|
11
|
-
|
12
|
-
* v4.4.1
|
13
|
-
* patch: added waitForTags param in useSearch hook for videos
|
14
|
-
|
15
|
-
* v4.4.0
|
16
|
-
* minor: PrimaryButton component props type set to any for now
|
17
|
-
* patch: isPurchasableAsVoucher added to PurchasableMonetization
|
18
|
-
* patch: voucherPurchase flag added to purchase overlays
|
19
|
-
* patch: item added to MonetizationsSelectOverlayData
|
20
|
-
* minor: added hungarian language to `LangCode` enum
|
21
|
-
|
22
|
-
* v4.3.0:
|
23
|
-
* minor: add GetPurchaseInfoResponse and PurchaseEndpointPayload to exported types
|
24
|
-
* minor: support for disabling purchase of specified subscriptions (new param in useOrganizationSubscriptions hook)
|
25
|
-
* minor: more specific PurchasableMonetization type usage instead of Monetization
|
26
|
-
* minor: monetization property deleted from Video type
|
27
|
-
* minor: monetization now has originalPrice and promotion properties available
|
28
|
-
* patch: remove not used OrganizationSubscriptionsContext, **this change requires bundle 3.20.0 or newer**
|
29
|
-
|
30
|
-
* v4.2.0:
|
31
|
-
* minor: fix useSearch loading type
|
32
|
-
* patch: added italian language to `LangCode` enum
|
33
|
-
|
34
|
-
* v4.1.0
|
35
|
-
* patch: added italian language to `LangCode` enum
|
36
|
-
* minor: fixed spanish language code in `LangCode` enum (`sp` -> `es`)
|
37
|
-
* minor: other misc type changes
|
38
|
-
|
39
|
-
* v4.0.1
|
40
|
-
* patch: added setBundleVersion setter to bundle type
|
41
|
-
* patch: added setStorageManager setter to bundle type
|
42
|
-
* patch: `Purchase.isPurchased` is deprecated
|
43
|
-
* patch: fill `useSearch` field `hasNextPage` with proper value
|
44
|
-
|
45
|
-
* v4.0.0
|
46
|
-
* minor: Types cleanup
|
47
|
-
* MAJOR: Remove deprecated and unused stuff
|
48
|
-
* auth
|
49
|
-
* changePassword
|
50
|
-
* changeUserPhoto
|
51
|
-
* removeUserPhoto
|
52
|
-
* getPurchasedVodsWithInitializedVideos
|
53
|
-
* initializeUser
|
54
|
-
* createFreePurchase
|
55
|
-
* components
|
56
|
-
* VideoAdBanner
|
57
|
-
* getters
|
58
|
-
* getExportedConfig
|
59
|
-
* getChannelById
|
60
|
-
* getSectionById
|
61
|
-
* getWidgetById
|
62
|
-
* hooks
|
63
|
-
* useLastVideoByWidgetId
|
64
|
-
* useScreen
|
65
|
-
* useFreePurchase
|
66
|
-
* useWidget
|
67
|
-
* useChannel
|
68
|
-
* useSection
|
69
|
-
* useVideosInSection
|
70
|
-
* useSectionsInChannel
|
71
|
-
* useChannelsInWidget
|
72
|
-
* subscriptions
|
73
|
-
* subscribeToWidget
|
74
|
-
* subscribeToChannel
|
75
|
-
* subscribeToSection
|
76
|
-
* subscribeToVideosInSection
|
77
|
-
* subscribeToSectionsInChannel
|
78
|
-
* subscribeToChannelsInWidget
|
79
|
-
* subscribeToScreen
|
80
|
-
---
|
81
|
-
_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)_
|
82
|
-
|
83
|
-
* v3.7.0
|
84
|
-
* minor: purchase contains created and updated
|
85
|
-
|
86
|
-
* v3.6.3
|
87
|
-
* patch: improve README.md
|
88
|
-
|
89
|
-
* v3.6.2
|
90
|
-
* patch: Fix types
|
91
|
-
|
92
|
-
* v3.6.1
|
93
|
-
* patch: Fix README
|
94
|
-
|
95
|
-
* v3.6.0
|
96
|
-
* minor: Update types
|
97
|
-
|
98
|
-
* v3.5.2
|
99
|
-
* patch: All types are available again.
|
100
|
-
|
101
|
-
* v3.5.1
|
102
|
-
* patch: remove incorrect dependency (@tivio/types)
|
103
|
-
|
104
|
-
* v3.5.0
|
105
|
-
* minor: Types change - Video.price and Video.detailedPrice can be null
|
106
|
-
* minor: Types change - Video.cover is marked as deprecated
|
107
|
-
|
108
|
-
* v3.4.0
|
109
|
-
* minor: more precise type for errors in usePurchaseRecovery and usePurchaseRecovery
|
110
|
-
* patch: jsdocs for usePurchaseRecovery and usePurchaseRecovery
|
111
|
-
* minor: inviteCodeReset in useApplyInviteCode
|
112
|
-
* minor: Reset forgotten password
|
113
|
-
* minor: Consolidating monetization logic
|
114
|
-
* v3.3.2
|
115
|
-
* patch: Adding new optional parameters (where, orderBy) to useTaggedVideos hook
|
116
|
-
* v3.3.1
|
117
|
-
* patch: Fixed types of `setUser`
|
118
|
-
* v3.3.0
|
119
|
-
* minor: Add getPlayerCapabilities to getters.
|
120
|
-
* patch: Added option to log out via `setUser(null)`, requires @tivio/core-react-dom@2.17.9
|
121
|
-
* v3.2.5
|
122
|
-
* patch: added recovery flag to QerkoPaymentInfo type
|
123
|
-
* patch: bundle.types changes - internal.components.WebVideoScreen
|
124
|
-
* patch: types changes - add new onBack prop to WebPlayerProps
|
125
|
-
* patch: Refactor useVideo hook, now uses hook from core-react
|
126
|
-
* v3.2.4
|
127
|
-
* minor: added useApplyInviteCode
|
128
|
-
* minor: better errors from useVoucher
|
129
|
-
* v3.2.3
|
130
|
-
* minor: added usePurchaseRecovery hook
|
131
|
-
* patch: deprecated `useLastVideoByWidgetId`
|
132
|
-
* v3.2.2
|
133
|
-
* minor: useRowsInScreen, useItemsInRow, useTaggedVideos - hasNextPage and loading added to pagination
|
134
|
-
* minor: useRowsInScreen, useItemsInRow, useTaggedVideos - implementation moved to remote bundle
|
135
|
-
* patch: Fixed Tivio startup on Tizen 6
|
136
|
-
* minor: Added `forceCloudFnResolver` option
|
137
|
-
* v3.2.1
|
138
|
-
* patch: fix of @tivio/common version
|
139
|
-
* v3.2.0
|
140
|
-
* minor: Added `capabilitiesOptions` for finer configuration of device capabilities
|
141
|
-
* minor: tag names are returned in correct language (the one from tivio config); language value should be one from enum "LangCode"
|
142
|
-
* v3.1.3
|
143
|
-
* patch: Hotfix made sure disabled Tivio does not break React Native
|
144
|
-
* v3.1.2
|
145
|
-
* patch: Allow `conf` prop of `TivioProvider` to be `null` or `undefined` in order to turn off Tivio
|
146
|
-
* v3.1.1
|
147
|
-
* patch: fixed `setUser()` crash when bundle fails to load
|
148
|
-
* v3.1.0
|
149
|
-
* patch: `useAdSegment()` now returns null if no monetization is configured, ad segments are not managed in that situation
|
150
|
-
* minor: enriched `AdSegment` type from `useAdSegment()`
|
151
|
-
* minor: Added `setUser()` function for login and logout
|
152
|
-
* v3.0.0
|
153
|
-
* minor: Added hook `useWatchWithoutAdsOffer` to trigger purchase dialog to "watch without ads", if available
|
154
|
-
* patch: fix peerDependency declaration for react, react-dom
|
155
|
-
* major: TivioProvider requires deviceCapabilities
|
156
|
-
* major: TivioProvider requires currency
|
157
|
-
* minor: add voucher support (see usePurchaseSubscription and useTransactionPayment hooks)
|
158
|
-
* minor: device limit support
|
159
|
-
* minor: drm (Widevine, PlayReady) support
|
160
|
-
* minor: watermarking support
|
161
|
-
* minor: add useSearch hook
|
162
|
-
* patch: price on video is 0 when purchased
|
163
|
-
* v2.4.2
|
164
|
-
* patch: added back changelog
|
165
|
-
* v2.4.1
|
166
|
-
* patch: improved doc about player wrapper
|
167
|
-
* v2.4.0
|
168
|
-
* patch: improved Player wrapper types
|
169
|
-
* minor: added Tivio DOM events `tivio_key_input_handling_change`, `tivio_context_switch` and `tivio_request_goto`
|
170
|
-
* 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)
|
171
|
-
* patch: added support for browsers that do not implement [indexedDB API](https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API)
|
172
|
-
* v2.3.4
|
173
|
-
* patch: fix of usePurchaseSubscription not reactive
|
174
|
-
* v2.3.3
|
175
|
-
* patch: fix of useUser not updating
|
176
|
-
* v2.3.2
|
177
|
-
* patch: next app doesn't fail anymore due to "self is not defined"
|
178
|
-
* v2.3.1
|
179
|
-
* patch: fix of @tivio/common dependency
|
180
|
-
* v2.3.0
|
181
|
-
* minor: add useTaggedVideos that allows to fetch videos with given tags
|
182
|
-
* minor: add option to fetch tags (on hook useItemsInRow), useVideo always fetching videos tags
|
183
|
-
* v2.2.1
|
184
|
-
* patch: disable Sentry when no config is supplied to `TivioProvider`
|
185
|
-
* v2.2.0
|
186
|
-
* patch: reduced bundle size
|
187
|
-
* 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 }`
|
188
|
-
* v2.1.5
|
189
|
-
* patch fix of `useVideosInSection` hook (fetching video's monetizations)
|
190
|
-
* v2.1.4
|
191
|
-
* patch: fix re-rendering of `useAd` during non-skippable ads (requires core-react-dom@2.1.9)
|
192
|
-
* v2.1.3
|
193
|
-
* patch: fix changelog
|
194
|
-
* v2.1.2
|
195
|
-
* patch: Fixed exported types
|
196
|
-
* v2.1.1
|
197
|
-
* patch: TivioWidget now correctly reports `false` via `onEnabled` callback when in invalid internal state
|
198
|
-
* v2.1.0
|
199
|
-
* patch: fix of useItemsInRow hook
|
200
|
-
* patch: fix of useScreen hook
|
201
|
-
* add: useRowsInScreen hook
|
202
|
-
* v2.0.3
|
203
|
-
* patch: fix of useItemsInRow hook
|
204
|
-
* v2.0.2
|
205
|
-
* patch: screen and row IDs fixed
|
206
|
-
* `TivioBundle.subscriptions.subscribeToItemsInRow` now accepts user-defined ID via studio.tiv.io
|
207
|
-
* `TivioBundle.subscriptions.subscribeToScreen` now accepts user-defined ID via studio.tiv.io
|
208
|
-
* `Screen` and `Row` types returned by `useScreen()` return their user-defined IDs (`.id`) correctly
|
209
|
-
* v2.0.1
|
210
|
-
* no changes
|
211
|
-
* v2.0.0
|
212
|
-
* major: video.channelId can now be `string | null` used to be `string`
|
213
|
-
* minor: added data API and hooks for screens (screens, rows of screen and row items)
|
214
|
-
* hooks: `useScreen()`, `useItemsInRow()`
|
215
|
-
* api: `TivioBundle.subscriptions.subscribeToScreen`, `TivioBundle.subscriptions.subscribeToItemsInRow`
|
216
|
-
* v1.3.6
|
217
|
-
* ?
|
218
|
-
* v1.3.5
|
219
|
-
* minor: added WebPlayer props (canReplay, showMarkers, customShortcuts, enableKeyboardShortcuts, source.poster)
|
220
|
-
* v1.3.4
|
221
|
-
* ...
|
222
|
-
|
223
|
-
|
224
|
-
## Installation
|
225
|
-
|
226
|
-
Install @tivio/sdk-react along with its peer dependencies
|
227
|
-
```sh
|
228
|
-
npm i react@17 react-dom@17 @tivio/sdk-react
|
229
|
-
# or
|
230
|
-
yarn add react@17 react-dom@17 @tivio/sdk-react
|
231
|
-
```
|
232
|
-
|
233
|
-
## Initialization
|
234
|
-
|
235
|
-
Put Tivio Provider at the top level of your application:
|
236
|
-
|
237
|
-
``` javascript
|
238
|
-
import { TivioProvider } from '@tivio/sdk-react'
|
239
|
-
|
240
|
-
const config = {
|
241
|
-
secret: 'XXXXXXXXXX',
|
242
|
-
}
|
243
|
-
|
244
|
-
function App({children}) {
|
245
|
-
return (
|
246
|
-
<TivioProvider conf={config}>
|
247
|
-
{children}
|
248
|
-
</TivioProvider>
|
249
|
-
)
|
250
|
-
}
|
251
|
-
```
|
252
|
-
|
253
|
-
## Authentication
|
254
|
-
|
255
|
-
A logged-in user can access more features, such as making purchases. In order to authenticate a user with Tivio, use the `setUser()` method.
|
256
|
-
|
257
|
-
Verification of the user against 3rd party auth servers is implemented per customer.
|
258
|
-
|
259
|
-
```typescript
|
260
|
-
import { setUser } from '@tivio/sdk-react'
|
261
|
-
|
262
|
-
// Log in
|
263
|
-
|
264
|
-
// Payload is specific per customer
|
265
|
-
// A common use-case is sending an auth token inside the payload, which Tivio can use to verify the user
|
266
|
-
await setUser('userId', { token: 'xxx'})
|
267
|
-
|
268
|
-
// Log out
|
269
|
-
await setUser(null)
|
270
|
-
```
|
271
|
-
|
272
|
-
## Player
|
273
|
-
|
274
|
-
You can choose whether you will use complete player component provided by Tivio or you will wrap your existing player
|
275
|
-
with the Tivio Player Wrapper.
|
276
|
-
|
277
|
-
### Tivio Player component
|
278
|
-
|
279
|
-
```javascript
|
280
|
-
import { useTivioData } from '@tivio/sdk-react'
|
281
|
-
|
282
|
-
const PlayerExample = () => {
|
283
|
-
const bundle = useTivioData()
|
284
|
-
|
285
|
-
if (!bundle?.components?.WebPlayer) {
|
286
|
-
return <p>Loading...</p>
|
287
|
-
}
|
288
|
-
|
289
|
-
return (
|
290
|
-
<>
|
291
|
-
<div
|
292
|
-
style={{
|
293
|
-
height: 720,
|
294
|
-
width: 1280,
|
295
|
-
}}
|
296
|
-
>
|
297
|
-
<bundle.components.WebPlayer
|
298
|
-
id="player1"
|
299
|
-
className="web-player"
|
300
|
-
source="/videos/xxxxxxxxxxxxxxxxxxxx" // dynamically change this based on video you want to play
|
301
|
-
/>
|
302
|
-
</div>
|
303
|
-
</>
|
304
|
-
)
|
305
|
-
}
|
306
|
-
```
|
307
|
-
|
308
|
-
### Player wrapper
|
309
|
-
|
310
|
-
Player wrapper is the way how you can enhance your video player with Tivio features, such Tivio Ads. In order to start
|
311
|
-
using Tivio player wrapper, wrap your player methods with PlayerWrapper, start using PlayerWrapper's methods
|
312
|
-
instead of them to control your playback and start sending player events to Tivio PlayerWrapper.
|
313
|
-
|
314
|
-
#### Wrap your player methods with Tivio player wrapper
|
315
|
-
|
316
|
-
```javascript
|
317
|
-
import { useTivioReadyData } from '@tivio/sdk-react'
|
318
|
-
|
319
|
-
function CustomPlayer() {
|
320
|
-
const tivioData = useTivioReadyData()
|
321
|
-
|
322
|
-
useEffect(() => {
|
323
|
-
if (tivioData) {
|
324
|
-
// If your app uses multiple player instances, use different Tivio player wrapper for each
|
325
|
-
// distinguished by playerWrapperId
|
326
|
-
const playerWrapper = tivio.getPlayerWrapper({ playerWrapperId: 'PLAYER_1' })
|
327
|
-
|
328
|
-
// Pass your player methods to Tivio player wrapper
|
329
|
-
playerWrapper.register({
|
330
|
-
play: () => {
|
331
|
-
// Un-pause your player
|
332
|
-
},
|
333
|
-
pause: () => {
|
334
|
-
// Pause your player
|
335
|
-
},
|
336
|
-
seekTo: (ms: number) => {
|
337
|
-
// Seek to position in milliseconds using your player
|
338
|
-
},
|
339
|
-
setSource: (videoSource: InputSource) => {
|
340
|
-
// Send this video source to your player to load it
|
341
|
-
},
|
342
|
-
})
|
343
|
-
}
|
344
|
-
}, [tivioData])
|
345
|
-
}
|
346
|
-
```
|
347
|
-
|
348
|
-
#### Start using Tivio player wrapper methods to control playback
|
349
|
-
|
350
|
-
```javascript
|
351
|
-
// Channel source metadata, such as channel name, epg start and epg end are necessary
|
352
|
-
// for TV ad segment detection and application of ad strategies
|
353
|
-
const source = new ChannelSource(
|
354
|
-
'https://channel_prima_hd.m3u8',
|
355
|
-
{
|
356
|
-
// here put any additional metadata, for your use.
|
357
|
-
// This object will not be touched by Tivio
|
358
|
-
},
|
359
|
-
// channel name
|
360
|
-
// can also be prima hd, prima_hd, prima, Prima, PRIMA, etc.
|
361
|
-
// we will normalize it to snake case and add '_hd' if necessary
|
362
|
-
'Prima HD',
|
363
|
-
// program name
|
364
|
-
'Dr. House',
|
365
|
-
// description (optional)
|
366
|
-
'Episode about Dr. House being awesome',
|
367
|
-
// EPG start
|
368
|
-
new Date('2021-12-10T12:00:00'),
|
369
|
-
// EPG end
|
370
|
-
new Date('2021-12-10T13:40:00'),
|
371
|
-
)
|
372
|
-
|
373
|
-
// Send source to player
|
374
|
-
playerWrapper.onSourceChanged(source)
|
375
|
-
|
376
|
-
// Un-pause player
|
377
|
-
playerWrapper.play()
|
378
|
-
|
379
|
-
// Pause player
|
380
|
-
playerWrapper.pause()
|
381
|
-
}
|
382
|
-
```
|
383
|
-
|
384
|
-
#### Start reporting player events to Tivio
|
385
|
-
|
386
|
-
```javascript
|
387
|
-
// Report that source is playing
|
388
|
-
playerWrapper.onStateChanged('playing')
|
389
|
-
|
390
|
-
// Report that source is paused
|
391
|
-
playerWrapper.onStateChanged('paused')
|
392
|
-
|
393
|
-
// Report that source stopped playing
|
394
|
-
playerWrapper.onPlaybackEnded()
|
395
|
-
playerWrapper.onStateChanged('idle')
|
396
|
-
|
397
|
-
// Report video progress
|
398
|
-
playerWrapper.onTimeChanged(ms)
|
399
|
-
}
|
400
|
-
```
|
401
|
-
|
402
|
-
#### Start reporting playback-related errors to Tivio
|
403
|
-
|
404
|
-
```javascript
|
405
|
-
// Report that video failed to load (e.g. due to a wrong URI)
|
406
|
-
playerWrapper.onLoadError(new Error('video failed to load'))
|
407
|
-
|
408
|
-
// Report that video failed during playback (e.g. due to bad connection, corrupted chunks of stream video etc.)
|
409
|
-
// This type of error may be auto-recoverable
|
410
|
-
playerWrapper.onError(new Error('playback error'))
|
411
|
-
}
|
412
|
-
```
|
413
|
-
|
414
|
-
## Data hooks
|
415
|
-
|
416
|
-
### useUser hook
|
417
|
-
Gets information about current user.
|
418
|
-
|
419
|
-
```ts
|
420
|
-
useUser: () => {
|
421
|
-
user: User | null
|
422
|
-
error: string | null
|
423
|
-
isInitialized: boolean
|
424
|
-
}
|
425
|
-
```
|
426
|
-
|
427
|
-
### useRowsInScreen hook
|
428
|
-
Gets array of Rows objects of specific screen and subscribes to its changes.
|
429
|
-
|
430
|
-
```ts
|
431
|
-
/**
|
432
|
-
* Use rows in screen
|
433
|
-
* @param screenId - screen id (from studio.tiv.io)
|
434
|
-
* @param options - subscription options
|
435
|
-
*/
|
436
|
-
useRowsInScreen: (screenId: string, options?: PaginationOptions) => {
|
437
|
-
pagination: PaginationInterface<Row> | null
|
438
|
-
error: Error | null
|
439
|
-
}
|
440
|
-
```
|
441
|
-
|
442
|
-
### useItemsInRow hook
|
443
|
-
Gets array of row items objects of specific row and subscribes to its changes.
|
444
|
-
|
445
|
-
```ts
|
446
|
-
/**
|
447
|
-
* Use row items
|
448
|
-
* @param rowId - row ID
|
449
|
-
* @param options - subscription options
|
450
|
-
*/
|
451
|
-
useItemsInRow: (rowId: string, options?: SubscribeToItemsInRowOptions) => {
|
452
|
-
pagination: PaginationInterface<ItemsInRow> | null
|
453
|
-
error: Error | null
|
454
|
-
}
|
455
|
-
```
|
456
|
-
|
457
|
-
### useVideo hook
|
458
|
-
|
459
|
-
Gets Video object and subscribes to its changes.
|
460
|
-
|
461
|
-
```ts
|
462
|
-
/**
|
463
|
-
* Use video
|
464
|
-
* @param videoId - video id
|
465
|
-
*/
|
466
|
-
useVideo: (videoId: string) => {
|
467
|
-
error: string | null;
|
468
|
-
data: Video | null;
|
469
|
-
}
|
470
|
-
```
|
471
|
-
|
472
|
-
### useTaggedVideos hook
|
473
|
-
Gets videos with given tag IDs.
|
474
|
-
|
475
|
-
```ts
|
476
|
-
/**
|
477
|
-
* Use tagged videos
|
478
|
-
* @param tagIds - tag ids
|
479
|
-
* @param options - subscription options
|
480
|
-
* @public
|
481
|
-
*/
|
482
|
-
useTaggedVideos: (tagIds: string[], options?: SubscribeToItemsInRowOptions) => {
|
483
|
-
pagination: PaginationInterface<Video> | null
|
484
|
-
error: Error | null
|
485
|
-
}
|
486
|
-
```
|