bitmovin-player-react-native 0.1.0 → 0.2.1
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 +163 -1
- package/RNBitmovinPlayer.podspec +3 -3
- package/android/src/main/java/com/bitmovin/player/reactnative/DrmModule.kt +191 -0
- package/android/src/main/java/com/bitmovin/player/reactnative/PlayerModule.kt +116 -101
- package/android/src/main/java/com/bitmovin/player/reactnative/RNPlayerView.kt +69 -38
- package/android/src/main/java/com/bitmovin/player/reactnative/RNPlayerViewManager.kt +10 -26
- package/android/src/main/java/com/bitmovin/player/reactnative/RNPlayerViewPackage.kt +3 -0
- package/android/src/main/java/com/bitmovin/player/reactnative/Registry.kt +11 -0
- package/android/src/main/java/com/bitmovin/player/reactnative/SourceModule.kt +178 -0
- package/android/src/main/java/com/bitmovin/player/reactnative/UuidModule.kt +20 -0
- package/android/src/main/java/com/bitmovin/player/reactnative/converter/JsonConverter.kt +128 -1
- package/android/src/main/java/com/bitmovin/player/reactnative/extensions/Events.kt +11 -2
- package/ios/DrmModule.m +16 -0
- package/ios/DrmModule.swift +442 -0
- package/ios/Event+JSON.swift +31 -0
- package/ios/PlayerModule.m +21 -25
- package/ios/PlayerModule.swift +122 -120
- package/ios/RCTConvert+BitmovinPlayer.swift +131 -12
- package/ios/RNPlayerView+PlayerListener.swift +12 -0
- package/ios/RNPlayerView.swift +5 -3
- package/ios/RNPlayerViewManager.m +3 -1
- package/ios/RNPlayerViewManager.swift +4 -21
- package/ios/Registry.swift +5 -0
- package/ios/SourceModule.m +30 -0
- package/ios/SourceModule.swift +187 -0
- package/ios/UuidModule.m +9 -0
- package/ios/UuidModule.swift +23 -0
- package/lib/index.d.ts +670 -235
- package/lib/index.js +257 -106
- package/lib/index.mjs +260 -112
- package/package.json +5 -4
- package/src/components/PlayerView/events.ts +24 -18
- package/src/components/PlayerView/index.tsx +29 -26
- package/src/drm/fairplayConfig.ts +90 -0
- package/src/drm/index.ts +178 -0
- package/src/drm/widevineConfig.ts +37 -0
- package/src/events.ts +67 -6
- package/src/hooks/useProxy.ts +19 -15
- package/src/index.ts +5 -3
- package/src/nativeInstance.ts +64 -0
- package/src/player.ts +51 -42
- package/src/source.ts +88 -8
- package/src/subtitleTrack.ts +60 -0
- package/src/utils.ts +15 -0
package/lib/index.d.ts
CHANGED
|
@@ -1,246 +1,73 @@
|
|
|
1
1
|
import { ViewStyle } from 'react-native';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Indicates media type DASH.
|
|
17
|
-
*/
|
|
18
|
-
DASH = "dash",
|
|
19
|
-
/**
|
|
20
|
-
* Indicates media type Progressive MP4.
|
|
21
|
-
*/
|
|
22
|
-
PROGRESSIVE = "progressive"
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* The different loading states a `Source` instance can be in.
|
|
4
|
+
* Utility type that maps the specified optional props from the target `Type` to be
|
|
5
|
+
* required props. Note all the other props stay unaffected.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* type MyType = {
|
|
9
|
+
* a?: string;
|
|
10
|
+
* b?: number;
|
|
11
|
+
* c?: boolean;
|
|
12
|
+
* };
|
|
13
|
+
*
|
|
14
|
+
* type MyRequiredType = MakeRequired<MyType, 'a' | 'c'> // => { a: string; b?: number; c: boolean; }
|
|
26
15
|
*/
|
|
27
|
-
declare
|
|
28
|
-
|
|
29
|
-
* The source is unloaded.
|
|
30
|
-
*/
|
|
31
|
-
UNLOADED = 0,
|
|
32
|
-
/**
|
|
33
|
-
* The source is currently loading.
|
|
34
|
-
*/
|
|
35
|
-
LOADING = 1,
|
|
36
|
-
/**
|
|
37
|
-
* The source is loaded.
|
|
38
|
-
*/
|
|
39
|
-
LOADED = 2
|
|
40
|
-
}
|
|
16
|
+
declare type MakeRequired<Type, Key extends keyof Type> = Omit<Type, Key> & Required<Pick<Type, Key>>;
|
|
17
|
+
|
|
41
18
|
/**
|
|
42
|
-
*
|
|
19
|
+
* Supported subtitle/caption file formats.
|
|
43
20
|
*/
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
url: string;
|
|
49
|
-
/**
|
|
50
|
-
* The `SourceType` for this configuration.
|
|
51
|
-
*/
|
|
52
|
-
type?: SourceType;
|
|
53
|
-
/**
|
|
54
|
-
* The title of the video source.
|
|
55
|
-
*/
|
|
56
|
-
title?: string;
|
|
57
|
-
/**
|
|
58
|
-
* The URL to a preview image displayed until the video starts.
|
|
59
|
-
*/
|
|
60
|
-
poster?: string;
|
|
61
|
-
/**
|
|
62
|
-
* Indicates whether to show the poster image during playback.
|
|
63
|
-
* Useful, for example, for audio-only streams.
|
|
64
|
-
*/
|
|
65
|
-
isPosterPersistent?: boolean;
|
|
21
|
+
declare enum SubtitleFormat {
|
|
22
|
+
CEA = "cea",
|
|
23
|
+
TTML = "ttml",
|
|
24
|
+
VTT = "vtt"
|
|
66
25
|
}
|
|
67
26
|
/**
|
|
68
|
-
* Represents
|
|
27
|
+
* Represents a custom subtitle track source that can be added to `SourceConfig.subtitleTracks`.
|
|
69
28
|
*/
|
|
70
|
-
interface
|
|
29
|
+
interface SubtitleTrack {
|
|
71
30
|
/**
|
|
72
|
-
* The
|
|
73
|
-
* Default value is `0` if the duration is not available or not known.
|
|
31
|
+
* The URL to the timed file, e.g. WebVTT file.
|
|
74
32
|
*/
|
|
75
|
-
|
|
33
|
+
url?: string;
|
|
76
34
|
/**
|
|
77
|
-
*
|
|
78
|
-
* Only one source can be active in the same player instance at any time.
|
|
35
|
+
* The label for this track.
|
|
79
36
|
*/
|
|
80
|
-
|
|
37
|
+
label?: string;
|
|
81
38
|
/**
|
|
82
|
-
*
|
|
39
|
+
* The unique identifier for this track. If no value is provided, a random UUIDv4 will be generated for it.
|
|
83
40
|
*/
|
|
84
|
-
|
|
41
|
+
identifier?: string;
|
|
85
42
|
/**
|
|
86
|
-
*
|
|
87
|
-
* Setting the metadata value for a source is not supported yet.
|
|
43
|
+
* Specifies the file format to be used by this track.
|
|
88
44
|
*/
|
|
89
|
-
|
|
45
|
+
format?: SubtitleFormat;
|
|
90
46
|
/**
|
|
91
|
-
*
|
|
47
|
+
* If set to true, this track would be considered as default. Default is `false`.
|
|
92
48
|
*/
|
|
93
|
-
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* Object used to configure a new `Player` instance.
|
|
98
|
-
*/
|
|
99
|
-
interface PlayerConfig {
|
|
49
|
+
isDefault?: boolean;
|
|
100
50
|
/**
|
|
101
|
-
*
|
|
51
|
+
* Tells if a subtitle track is forced. If set to `true` it means that the player should automatically
|
|
52
|
+
* select and switch this subtitle according to the selected audio language. Forced subtitles do
|
|
53
|
+
* not appear in `Player.getAvailableSubtitles`.
|
|
102
54
|
*
|
|
103
|
-
*
|
|
104
|
-
* @example
|
|
105
|
-
* Accessing or creating the `Player` with `nativeId` equal to `my-player`:
|
|
106
|
-
* ```
|
|
107
|
-
* const player = new Player({ nativeId: 'my-player' })
|
|
108
|
-
* player.play(); // call methods and properties...
|
|
109
|
-
* ```
|
|
55
|
+
* Default is `false`.
|
|
110
56
|
*/
|
|
111
|
-
|
|
57
|
+
isForced?: boolean;
|
|
112
58
|
/**
|
|
113
|
-
*
|
|
114
|
-
* If a license key is set here, it will be used instead of the license key found in the `Info.plist` and `AndroidManifest.xml`.
|
|
115
|
-
* @example
|
|
116
|
-
* Configuring the player license key from source code:
|
|
117
|
-
* ```
|
|
118
|
-
* const player = new Player({
|
|
119
|
-
* licenseKey: '\<LICENSE-KEY-CODE\>',
|
|
120
|
-
* });
|
|
121
|
-
* ```
|
|
122
|
-
* @example
|
|
123
|
-
* `licenseKey` can be safely omitted from source code if it has
|
|
124
|
-
* been configured in Info.plist/AndroidManifest.xml.
|
|
125
|
-
* ```
|
|
126
|
-
* const player = new Player(); // omit `licenseKey`
|
|
127
|
-
* player.play(); // call methods and properties...
|
|
128
|
-
* ```
|
|
59
|
+
* The IETF BCP 47 language tag associated with this track, e.g. `pt`, `en`, `es` etc.
|
|
129
60
|
*/
|
|
130
|
-
|
|
61
|
+
language?: string;
|
|
131
62
|
}
|
|
132
63
|
/**
|
|
133
|
-
*
|
|
134
|
-
* instance can be created via the `usePlayer` hook and will idle until one or more `Source`s are
|
|
135
|
-
* loaded. Once `load` is called, the player becomes active and initiates necessary downloads to
|
|
136
|
-
* start playback of the loaded source(s).
|
|
64
|
+
* Helper type that represents an entry in `SourceConfig.subtitleTracks` list.
|
|
137
65
|
*
|
|
138
|
-
*
|
|
139
|
-
*
|
|
66
|
+
* Since `SubtitleTrack` has all of its properties as optionals for total compatibility with
|
|
67
|
+
* values that may be sent from native code, this type serves as a reinforcer of what properties
|
|
68
|
+
* should be required during the registration of an external subtitle track from JS.
|
|
140
69
|
*/
|
|
141
|
-
declare
|
|
142
|
-
/**
|
|
143
|
-
* User-defined `nativeId` string or random `UUIDv4` identifying this `Player` in the native side.
|
|
144
|
-
*/
|
|
145
|
-
readonly nativeId: string;
|
|
146
|
-
/**
|
|
147
|
-
* Configuration object used to initialize this `Player`.
|
|
148
|
-
*/
|
|
149
|
-
readonly config: PlayerConfig | null;
|
|
150
|
-
constructor(config?: PlayerConfig);
|
|
151
|
-
/**
|
|
152
|
-
* Loads a new `Source` into the player.
|
|
153
|
-
*/
|
|
154
|
-
load: (source: SourceConfig) => void;
|
|
155
|
-
/**
|
|
156
|
-
* Unloads all `Source`s from the player.
|
|
157
|
-
*/
|
|
158
|
-
unload: () => void;
|
|
159
|
-
/**
|
|
160
|
-
* Starts or resumes playback after being paused. Has no effect if the player is already playing.
|
|
161
|
-
*/
|
|
162
|
-
play: () => void;
|
|
163
|
-
/**
|
|
164
|
-
* Pauses the video if it is playing. Has no effect if the player is already paused.
|
|
165
|
-
*/
|
|
166
|
-
pause: () => void;
|
|
167
|
-
/**
|
|
168
|
-
* Seeks to the given playback time specified by the parameter `time` in seconds. Must not be
|
|
169
|
-
* greater than the total duration of the video. Has no effect when watching a live stream since
|
|
170
|
-
* seeking is not possible.
|
|
171
|
-
*
|
|
172
|
-
* @param time - The time to seek to in seconds.
|
|
173
|
-
*/
|
|
174
|
-
seek: (time: number) => void;
|
|
175
|
-
/**
|
|
176
|
-
* Mutes the player if an audio track is available. Has no effect if the player is already muted.
|
|
177
|
-
*/
|
|
178
|
-
mute: () => void;
|
|
179
|
-
/**
|
|
180
|
-
* Unmutes the player if it is muted. Has no effect if the player is already unmuted.
|
|
181
|
-
*/
|
|
182
|
-
unmute: () => void;
|
|
183
|
-
/**
|
|
184
|
-
* Destroys the player and releases all of its allocated resources.
|
|
185
|
-
* The player instance must not be used after calling this method.
|
|
186
|
-
*/
|
|
187
|
-
destroy: () => void;
|
|
188
|
-
/**
|
|
189
|
-
* Sets the player's volume between 0 (silent) and 100 (max volume).
|
|
190
|
-
*
|
|
191
|
-
* @param volume - The volume level to set.
|
|
192
|
-
*/
|
|
193
|
-
setVolume: (volume: number) => void;
|
|
194
|
-
/**
|
|
195
|
-
* @returns The currently active source or null if no source is active.
|
|
196
|
-
*/
|
|
197
|
-
getSource: () => Promise<Source>;
|
|
198
|
-
/**
|
|
199
|
-
* @returns The player's current volume level.
|
|
200
|
-
*/
|
|
201
|
-
getVolume: () => Promise<number>;
|
|
202
|
-
/**
|
|
203
|
-
* @returns The current playback time in seconds.
|
|
204
|
-
*
|
|
205
|
-
* For VoD streams the returned time ranges between 0 and the duration of the asset.
|
|
206
|
-
*
|
|
207
|
-
* For live streams it can be specified if an absolute UNIX timestamp or a value
|
|
208
|
-
* relative to the playback start should be returned.
|
|
209
|
-
*
|
|
210
|
-
* @param mode - The time mode to specify: an absolute UNIX timestamp ('absolute') or relative time ('relative').
|
|
211
|
-
*/
|
|
212
|
-
getCurrentTime: (mode?: "relative" | "absolute" | undefined) => Promise<number>;
|
|
213
|
-
/**
|
|
214
|
-
* @returns The total duration in seconds of the current video or INFINITY if it’s a live stream.
|
|
215
|
-
*/
|
|
216
|
-
getDuration: () => Promise<number>;
|
|
217
|
-
/**
|
|
218
|
-
* @returns `true` if the player is muted.
|
|
219
|
-
*/
|
|
220
|
-
isMuted: () => Promise<boolean>;
|
|
221
|
-
/**
|
|
222
|
-
* @returns `true` if the player is currently playing, i.e. has started and is not paused.
|
|
223
|
-
*/
|
|
224
|
-
isPlaying: () => Promise<boolean>;
|
|
225
|
-
/**
|
|
226
|
-
* @returns `true` if the player has started playback but it's currently paused.
|
|
227
|
-
*/
|
|
228
|
-
isPaused: () => Promise<boolean>;
|
|
229
|
-
/**
|
|
230
|
-
* @returns `true` if the displayed video is a live stream.
|
|
231
|
-
*/
|
|
232
|
-
isLive: () => Promise<boolean>;
|
|
233
|
-
/**
|
|
234
|
-
* @remarks Only available for iOS devices.
|
|
235
|
-
* @returns `true` when media is played externally using AirPlay.
|
|
236
|
-
*/
|
|
237
|
-
isAirPlayActive: () => Promise<boolean>;
|
|
238
|
-
/**
|
|
239
|
-
* @remarks Only available for iOS devices.
|
|
240
|
-
* @returns `true` when AirPlay is available.
|
|
241
|
-
*/
|
|
242
|
-
isAirPlayAvailable: () => Promise<boolean>;
|
|
243
|
-
}
|
|
70
|
+
declare type SideLoadedSubtitleTrack = MakeRequired<SubtitleTrack, 'url' | 'label' | 'language' | 'format'>;
|
|
244
71
|
|
|
245
72
|
/**
|
|
246
73
|
* Base event type for all events.
|
|
@@ -341,6 +168,32 @@ interface PlayingEvent extends Event {
|
|
|
341
168
|
*/
|
|
342
169
|
interface PlaybackFinishedEvent extends Event {
|
|
343
170
|
}
|
|
171
|
+
/**
|
|
172
|
+
* Source object representation the way it appears on `Event` payloads such as `SeekEvent`, for example.
|
|
173
|
+
*
|
|
174
|
+
* This interface only type hints what should be the shape of a `Source` object inside an `Event`'s
|
|
175
|
+
* payload during runtime so it has no direct relation with the `Source` class present in `src/source.ts`.
|
|
176
|
+
*
|
|
177
|
+
* Do not mistake it for a `NativeInstance` type.
|
|
178
|
+
*/
|
|
179
|
+
interface EventSource {
|
|
180
|
+
/**
|
|
181
|
+
* Event's source duration in seconds.
|
|
182
|
+
*/
|
|
183
|
+
duration: number;
|
|
184
|
+
/**
|
|
185
|
+
* Whether this event's source is currently active in a player.
|
|
186
|
+
*/
|
|
187
|
+
isActive: boolean;
|
|
188
|
+
/**
|
|
189
|
+
* Whether this event's source is currently attached to a player instance.
|
|
190
|
+
*/
|
|
191
|
+
isAttachedToPlayer: boolean;
|
|
192
|
+
/**
|
|
193
|
+
* Metadata for this event's source.
|
|
194
|
+
*/
|
|
195
|
+
metadata?: Record<string, any>;
|
|
196
|
+
}
|
|
344
197
|
/**
|
|
345
198
|
* Emitted when the player is about to seek to a new position.
|
|
346
199
|
* Only applies to VoD streams.
|
|
@@ -351,14 +204,14 @@ interface SeekEvent extends Event {
|
|
|
351
204
|
*/
|
|
352
205
|
from: {
|
|
353
206
|
time: number;
|
|
354
|
-
source:
|
|
207
|
+
source: EventSource;
|
|
355
208
|
};
|
|
356
209
|
/**
|
|
357
210
|
* Added source metadata.
|
|
358
211
|
*/
|
|
359
212
|
to: {
|
|
360
213
|
time: number;
|
|
361
|
-
source:
|
|
214
|
+
source: EventSource;
|
|
362
215
|
};
|
|
363
216
|
}
|
|
364
217
|
/**
|
|
@@ -384,7 +237,7 @@ interface SourceLoadEvent extends Event {
|
|
|
384
237
|
/**
|
|
385
238
|
* Source that is about to load.
|
|
386
239
|
*/
|
|
387
|
-
source:
|
|
240
|
+
source: EventSource;
|
|
388
241
|
}
|
|
389
242
|
/**
|
|
390
243
|
* Emitted when a new source is loaded.
|
|
@@ -394,7 +247,7 @@ interface SourceLoadedEvent extends Event {
|
|
|
394
247
|
/**
|
|
395
248
|
* Source that was loaded into player.
|
|
396
249
|
*/
|
|
397
|
-
source:
|
|
250
|
+
source: EventSource;
|
|
398
251
|
}
|
|
399
252
|
/**
|
|
400
253
|
* Emitted when the current source has been unloaded.
|
|
@@ -403,7 +256,7 @@ interface SourceUnloadedEvent extends Event {
|
|
|
403
256
|
/**
|
|
404
257
|
* Source that was unloaded from player.
|
|
405
258
|
*/
|
|
406
|
-
source:
|
|
259
|
+
source: EventSource;
|
|
407
260
|
}
|
|
408
261
|
/**
|
|
409
262
|
* Emitted when a source error happens.
|
|
@@ -415,38 +268,66 @@ interface SourceErrorEvent extends ErrorEvent {
|
|
|
415
268
|
*/
|
|
416
269
|
interface SourceWarningEvent extends ErrorEvent {
|
|
417
270
|
}
|
|
418
|
-
|
|
419
271
|
/**
|
|
420
|
-
*
|
|
421
|
-
* that can be used inside any component.
|
|
272
|
+
* Emitted when a new subtitle track is added to the player.
|
|
422
273
|
*/
|
|
423
|
-
|
|
274
|
+
interface SubtitleAddedEvent extends Event {
|
|
275
|
+
/**
|
|
276
|
+
* Subtitle track that has been added.
|
|
277
|
+
*/
|
|
278
|
+
subtitleTrack: SubtitleTrack;
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Emitted when a subtitle track is removed from the player.
|
|
282
|
+
*/
|
|
283
|
+
interface SubtitleRemovedEvent extends Event {
|
|
284
|
+
/**
|
|
285
|
+
* Subtitle track that has been removed.
|
|
286
|
+
*/
|
|
287
|
+
subtitleTrack: SubtitleTrack;
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Emitted when the player's selected subtitle track has changed.
|
|
291
|
+
*/
|
|
292
|
+
interface SubtitleChangedEvent extends Event {
|
|
293
|
+
/**
|
|
294
|
+
* Subtitle track that was previously selected.
|
|
295
|
+
*/
|
|
296
|
+
oldSubtitleTrack: SubtitleTrack;
|
|
297
|
+
/**
|
|
298
|
+
* Subtitle track that is selected now.
|
|
299
|
+
*/
|
|
300
|
+
newSubtitleTrack: SubtitleTrack;
|
|
301
|
+
}
|
|
424
302
|
|
|
425
303
|
/**
|
|
426
304
|
* Type that defines all event props supported by `PlayerView` and `NativePlayerView`.
|
|
427
305
|
* Used to generate the specific events interface for each component.
|
|
428
306
|
*/
|
|
429
307
|
interface EventProps {
|
|
430
|
-
onEvent: Event;
|
|
431
|
-
onPlayerActive: PlayerActiveEvent;
|
|
432
|
-
onPlayerError: PlayerErrorEvent;
|
|
433
|
-
onPlayerWarning: PlayerWarningEvent;
|
|
434
308
|
onDestroy: DestroyEvent;
|
|
309
|
+
onEvent: Event;
|
|
435
310
|
onMuted: MutedEvent;
|
|
436
|
-
onUnmuted: UnmutedEvent;
|
|
437
|
-
onReady: ReadyEvent;
|
|
438
311
|
onPaused: PausedEvent;
|
|
439
312
|
onPlay: PlayEvent;
|
|
440
|
-
onPlaying: PlayingEvent;
|
|
441
313
|
onPlaybackFinished: PlaybackFinishedEvent;
|
|
314
|
+
onPlayerActive: PlayerActiveEvent;
|
|
315
|
+
onPlayerError: PlayerErrorEvent;
|
|
316
|
+
onPlayerWarning: PlayerWarningEvent;
|
|
317
|
+
onPlaying: PlayingEvent;
|
|
318
|
+
onReady: ReadyEvent;
|
|
442
319
|
onSeek: SeekEvent;
|
|
443
320
|
onSeeked: SeekedEvent;
|
|
444
|
-
|
|
321
|
+
onSourceError: SourceErrorEvent;
|
|
445
322
|
onSourceLoad: SourceLoadEvent;
|
|
446
323
|
onSourceLoaded: SourceLoadedEvent;
|
|
447
324
|
onSourceUnloaded: SourceUnloadedEvent;
|
|
448
|
-
onSourceError: SourceErrorEvent;
|
|
449
325
|
onSourceWarning: SourceWarningEvent;
|
|
326
|
+
onSubtitleAdded: SubtitleAddedEvent;
|
|
327
|
+
onSubtitleChanged: SubtitleChangedEvent;
|
|
328
|
+
onSubtitleRemoved: SubtitleRemovedEvent;
|
|
329
|
+
onTimeChanged: TimeChangedEvent;
|
|
330
|
+
onUnmuted: UnmutedEvent;
|
|
450
331
|
}
|
|
451
332
|
/**
|
|
452
333
|
* Event props for `PlayerView`.
|
|
@@ -458,7 +339,555 @@ declare type PlayerViewEvents = {
|
|
|
458
339
|
[Prop in keyof EventProps]?: (event: EventProps[Prop]) => void;
|
|
459
340
|
};
|
|
460
341
|
|
|
461
|
-
|
|
342
|
+
interface NativeInstanceConfig {
|
|
343
|
+
/**
|
|
344
|
+
* Optionally user-defined string `id` for the native instance.
|
|
345
|
+
* Used to access a certain native instance from any point in the source code then call
|
|
346
|
+
* methods/properties on it.
|
|
347
|
+
*
|
|
348
|
+
* When left empty, a random `UUIDv4` is generated for it.
|
|
349
|
+
* @example
|
|
350
|
+
* Accessing or creating the `Player` with `nativeId` equal to `my-player`:
|
|
351
|
+
* ```
|
|
352
|
+
* const player = new Player({ nativeId: 'my-player' })
|
|
353
|
+
* player.play(); // call methods and properties...
|
|
354
|
+
* ```
|
|
355
|
+
*/
|
|
356
|
+
nativeId?: string;
|
|
357
|
+
}
|
|
358
|
+
declare abstract class NativeInstance<Config extends NativeInstanceConfig> {
|
|
359
|
+
/**
|
|
360
|
+
* Optionally user-defined string `id` for the native instance, or UUIDv4.
|
|
361
|
+
*/
|
|
362
|
+
readonly nativeId: string;
|
|
363
|
+
/**
|
|
364
|
+
* The configuration object used to initialize this instance.
|
|
365
|
+
*/
|
|
366
|
+
readonly config?: Config;
|
|
367
|
+
/**
|
|
368
|
+
* Generate UUID in case the user-defined `nativeId` is empty.
|
|
369
|
+
*/
|
|
370
|
+
constructor(config?: Config);
|
|
371
|
+
/**
|
|
372
|
+
* Flag indicating whether the native resources of this object have been created internally
|
|
373
|
+
* .i.e `initialize` has been called.
|
|
374
|
+
*/
|
|
375
|
+
abstract isInitialized: boolean;
|
|
376
|
+
/**
|
|
377
|
+
* Create the native object/resources that will be managed by this instance.
|
|
378
|
+
*/
|
|
379
|
+
abstract initialize(): void;
|
|
380
|
+
/**
|
|
381
|
+
* Flag indicating whether the native resources of this object have been disposed .i.e
|
|
382
|
+
* `destroy` has been called.
|
|
383
|
+
*/
|
|
384
|
+
abstract isDestroyed: boolean;
|
|
385
|
+
/**
|
|
386
|
+
* Dispose the native object/resources created by this instance during `initialize`.
|
|
387
|
+
*/
|
|
388
|
+
abstract destroy(): void;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
/**
|
|
392
|
+
* Represents a FairPlay Streaming DRM config.
|
|
393
|
+
*/
|
|
394
|
+
interface FairplayConfig {
|
|
395
|
+
/**
|
|
396
|
+
* The DRM license acquisition URL.
|
|
397
|
+
*/
|
|
398
|
+
licenseUrl: string;
|
|
399
|
+
/**
|
|
400
|
+
* The URL to the FairPlay Streaming certificate of the license server.
|
|
401
|
+
*/
|
|
402
|
+
certificateUrl?: string;
|
|
403
|
+
/**
|
|
404
|
+
* A dictionary to specify custom HTTP headers for the license request.
|
|
405
|
+
*/
|
|
406
|
+
licenseRequestHeaders?: Record<string, string>;
|
|
407
|
+
/**
|
|
408
|
+
* A dictionary to specify custom HTTP headers for the certificate request.
|
|
409
|
+
*/
|
|
410
|
+
certificateRequestHeaders?: Record<string, string>;
|
|
411
|
+
/**
|
|
412
|
+
* A block to prepare the loaded certificate before building SPC data and passing it into the
|
|
413
|
+
* system. This is needed if the server responds with anything else than the certificate, e.g. if
|
|
414
|
+
* the certificate is wrapped into a JSON object. The server response for the certificate request
|
|
415
|
+
* is passed as parameter “as is”.
|
|
416
|
+
*
|
|
417
|
+
* Note that both the passed `certificate` data and this block return value should be a Base64
|
|
418
|
+
* string. So use whatever solution suits you best to handle Base64 in React Native.
|
|
419
|
+
*
|
|
420
|
+
* @param certificate - Base64 encoded certificate data.
|
|
421
|
+
* @returns The processed Base64 encoded certificate.
|
|
422
|
+
*/
|
|
423
|
+
prepareCertificate?: (certificate: string) => string;
|
|
424
|
+
/**
|
|
425
|
+
* A block to prepare the data which is sent as the body of the POST license request.
|
|
426
|
+
* As many DRM providers expect different, vendor-specific messages, this can be done using
|
|
427
|
+
* this user-defined block.
|
|
428
|
+
*
|
|
429
|
+
* Note that both the passed `message` data and this block return value should be a Base64 string.
|
|
430
|
+
* So use whatever solution suits you best to handle Base64 in React Native.
|
|
431
|
+
*
|
|
432
|
+
* @param message - Base64 encoded message data.
|
|
433
|
+
* @param assetId - Stream asset ID.
|
|
434
|
+
* @returns The processed Base64 encoded message.
|
|
435
|
+
*/
|
|
436
|
+
prepareMessage?: (message: string, assetId: string) => string;
|
|
437
|
+
/**
|
|
438
|
+
* A block to prepare the data which is sent as the body of the POST request for syncing the DRM
|
|
439
|
+
* license information.
|
|
440
|
+
*
|
|
441
|
+
* Note that both the passed `syncMessage` data and this block return value should be a Base64
|
|
442
|
+
* string. So use whatever solution suits you best to handle Base64 in React Native.
|
|
443
|
+
*
|
|
444
|
+
* @param message - Base64 encoded message data.
|
|
445
|
+
* @param assetId - Asset ID.
|
|
446
|
+
* @returns The processed Base64 encoded sync message.
|
|
447
|
+
*/
|
|
448
|
+
prepareSyncMessage?: (syncMessage: string, assetId: string) => string;
|
|
449
|
+
/**
|
|
450
|
+
* A block to prepare the loaded CKC Data before passing it to the system. This is needed if the
|
|
451
|
+
* server responds with anything else than the license, e.g. if the license is wrapped into a JSON
|
|
452
|
+
* object.
|
|
453
|
+
*
|
|
454
|
+
* Note that both the passed `license` data and this block return value should be a Base64 string.
|
|
455
|
+
* So use whatever solution suits you best to handle Base64 in React Native.
|
|
456
|
+
*
|
|
457
|
+
* @param license - Base64 encoded license data.
|
|
458
|
+
* @returns The processed Base64 encoded license.
|
|
459
|
+
*/
|
|
460
|
+
prepareLicense?: (license: string) => string;
|
|
461
|
+
/**
|
|
462
|
+
* A block to prepare the URI (without the skd://) from the HLS manifest before passing it to the
|
|
463
|
+
* system.
|
|
464
|
+
*
|
|
465
|
+
* @param licenseServerUrl - License server URL string.
|
|
466
|
+
* @returns The processed license server URL string.
|
|
467
|
+
*/
|
|
468
|
+
prepareLicenseServerUrl?: (licenseServerUrl: string) => string;
|
|
469
|
+
/**
|
|
470
|
+
* A block to prepare the `contentId`, which is sent to the FairPlay Streaming license server as
|
|
471
|
+
* request body, and which is used to build the SPC data. As many DRM providers expect different,
|
|
472
|
+
* vendor-specific messages, this can be done using this user-defined block. The parameter is the
|
|
473
|
+
* skd:// URI extracted from the HLS manifest (m3u8) and the return value should be the contentID
|
|
474
|
+
* as string.
|
|
475
|
+
*
|
|
476
|
+
* @param contentId - Extracted content id string.
|
|
477
|
+
* @returns The processed contentId.
|
|
478
|
+
*/
|
|
479
|
+
prepareContentId?: (contentId: string) => string;
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
/**
|
|
483
|
+
* Represents a Widevine Streaming DRM config.
|
|
484
|
+
*/
|
|
485
|
+
interface WidevineConfig {
|
|
486
|
+
/**
|
|
487
|
+
* The DRM license acquisition URL.
|
|
488
|
+
*/
|
|
489
|
+
licenseUrl: string;
|
|
490
|
+
/**
|
|
491
|
+
* A block to prepare the data which is sent as the body of the POST license request.
|
|
492
|
+
* As many DRM providers expect different, vendor-specific messages, this can be done using
|
|
493
|
+
* this user-defined block.
|
|
494
|
+
*
|
|
495
|
+
* Note that both the passed `message` data and this block return value should be a Base64 string.
|
|
496
|
+
* So use whatever solution suits you best to handle Base64 in React Native.
|
|
497
|
+
*
|
|
498
|
+
* @param message - Base64 encoded message data.
|
|
499
|
+
* @returns The processed Base64 encoded message.
|
|
500
|
+
*/
|
|
501
|
+
prepareMessage?: (message: string) => string;
|
|
502
|
+
/**
|
|
503
|
+
* A block to prepare the loaded CKC Data before passing it to the system. This is needed if the
|
|
504
|
+
* server responds with anything else than the license, e.g. if the license is wrapped into a JSON
|
|
505
|
+
* object.
|
|
506
|
+
*
|
|
507
|
+
* Note that both the passed `license` data and this block return value should be a Base64 string.
|
|
508
|
+
* So use whatever solution suits you best to handle Base64 in React Native.
|
|
509
|
+
*
|
|
510
|
+
* @param license - Base64 encoded license data.
|
|
511
|
+
* @returns The processed Base64 encoded license.
|
|
512
|
+
*/
|
|
513
|
+
prepareLicense?: (license: string) => string;
|
|
514
|
+
/**
|
|
515
|
+
* Set widevine's preferred security level. Android only.
|
|
516
|
+
*/
|
|
517
|
+
preferredSecurityLevel?: string;
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
/**
|
|
521
|
+
* Represents the general Streaming DRM config.
|
|
522
|
+
*/
|
|
523
|
+
interface DrmConfig extends NativeInstanceConfig {
|
|
524
|
+
/**
|
|
525
|
+
* FairPlay specific configuration. Only applicable for iOS.
|
|
526
|
+
*/
|
|
527
|
+
fairplay?: FairplayConfig;
|
|
528
|
+
/**
|
|
529
|
+
* Widevine specific configuration. Only applicable for Android.
|
|
530
|
+
*/
|
|
531
|
+
widevine?: WidevineConfig;
|
|
532
|
+
}
|
|
533
|
+
/**
|
|
534
|
+
* Represents a native DRM configuration object.
|
|
535
|
+
*/
|
|
536
|
+
declare class Drm extends NativeInstance<DrmConfig> {
|
|
537
|
+
/**
|
|
538
|
+
* Whether this object's native instance has been created.
|
|
539
|
+
*/
|
|
540
|
+
isInitialized: boolean;
|
|
541
|
+
/**
|
|
542
|
+
* Whether this object's native instance has been disposed.
|
|
543
|
+
*/
|
|
544
|
+
isDestroyed: boolean;
|
|
545
|
+
/**
|
|
546
|
+
* Allocates the DRM config instance and its resources natively.
|
|
547
|
+
*/
|
|
548
|
+
initialize: () => void;
|
|
549
|
+
/**
|
|
550
|
+
* Destroys the native DRM config and releases all of its allocated resources.
|
|
551
|
+
*/
|
|
552
|
+
destroy: () => void;
|
|
553
|
+
/**
|
|
554
|
+
* iOS only.
|
|
555
|
+
*
|
|
556
|
+
* Applies the user-defined `prepareCertificate` function to native's `certificate` data and store
|
|
557
|
+
* the result back in `DrmModule`.
|
|
558
|
+
*
|
|
559
|
+
* Called from native code when `FairplayConfig.prepareCertificate` is dispatched.
|
|
560
|
+
*
|
|
561
|
+
* @param certificate - Base64 encoded certificate data.
|
|
562
|
+
*/
|
|
563
|
+
onPrepareCertificate: (certificate: string) => void;
|
|
564
|
+
/**
|
|
565
|
+
* Applies the user-defined `prepareMessage` function to native's `message` data and store
|
|
566
|
+
* the result back in `DrmModule`.
|
|
567
|
+
*
|
|
568
|
+
* Called from native code when `prepareMessage` is dispatched.
|
|
569
|
+
*
|
|
570
|
+
* @param message - Base64 encoded message data.
|
|
571
|
+
* @param assetId - Optional asset ID. Only sent by iOS.
|
|
572
|
+
*/
|
|
573
|
+
onPrepareMessage: (message: string, assetId?: string | undefined) => void;
|
|
574
|
+
/**
|
|
575
|
+
* iOS only.
|
|
576
|
+
*
|
|
577
|
+
* Applies the user-defined `prepareSyncMessage` function to native's `syncMessage` data and
|
|
578
|
+
* store the result back in `DrmModule`.
|
|
579
|
+
*
|
|
580
|
+
* Called from native code when `FairplayConfig.prepareSyncMessage` is dispatched.
|
|
581
|
+
*
|
|
582
|
+
* @param syncMessage - Base64 encoded sync SPC message data.
|
|
583
|
+
*/
|
|
584
|
+
onPrepareSyncMessage: (syncMessage: string, assetId: string) => void;
|
|
585
|
+
/**
|
|
586
|
+
* Applies the user-defined `prepareLicense` function to native's `license` data and store
|
|
587
|
+
* the result back in `DrmModule`.
|
|
588
|
+
*
|
|
589
|
+
* Called from native code when `prepareLicense` is dispatched.
|
|
590
|
+
*
|
|
591
|
+
* @param license - Base64 encoded license data.
|
|
592
|
+
*/
|
|
593
|
+
onPrepareLicense: (license: string) => void;
|
|
594
|
+
/**
|
|
595
|
+
* iOS only.
|
|
596
|
+
*
|
|
597
|
+
* Applies the user-defined `prepareLicenseServerUrl` function to native's `licenseServerUrl` data
|
|
598
|
+
* and store the result back in `DrmModule`.
|
|
599
|
+
*
|
|
600
|
+
* Called from native code when `FairplayConfig.prepareLicenseServerUrl` is dispatched.
|
|
601
|
+
*
|
|
602
|
+
* @param licenseServerUrl - The license server URL string.
|
|
603
|
+
*/
|
|
604
|
+
onPrepareLicenseServerUrl: (licenseServerUrl: string) => void;
|
|
605
|
+
/**
|
|
606
|
+
* iOS only.
|
|
607
|
+
*
|
|
608
|
+
* Applies the user-defined `prepareContentId` function to native's `contentId` string
|
|
609
|
+
* and store the result back in `DrmModule`.
|
|
610
|
+
*
|
|
611
|
+
* Called from native code when `FairplayConfig.prepareContentId` is dispatched.
|
|
612
|
+
*
|
|
613
|
+
* @param contentId - The extracted contentId string.
|
|
614
|
+
*/
|
|
615
|
+
onPrepareContentId: (contentId: string) => void;
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
/**
|
|
619
|
+
* Types of media that can be handled by the player.
|
|
620
|
+
*/
|
|
621
|
+
declare enum SourceType {
|
|
622
|
+
/**
|
|
623
|
+
* Indicates a missing source type.
|
|
624
|
+
*/
|
|
625
|
+
NONE = "none",
|
|
626
|
+
/**
|
|
627
|
+
* Indicates media type HLS.
|
|
628
|
+
*/
|
|
629
|
+
HLS = "hls",
|
|
630
|
+
/**
|
|
631
|
+
* Indicates media type DASH.
|
|
632
|
+
*/
|
|
633
|
+
DASH = "dash",
|
|
634
|
+
/**
|
|
635
|
+
* Indicates media type Progressive MP4.
|
|
636
|
+
*/
|
|
637
|
+
PROGRESSIVE = "progressive"
|
|
638
|
+
}
|
|
639
|
+
/**
|
|
640
|
+
* The different loading states a `Source` instance can be in.
|
|
641
|
+
*/
|
|
642
|
+
declare enum LoadingState {
|
|
643
|
+
/**
|
|
644
|
+
* The source is unloaded.
|
|
645
|
+
*/
|
|
646
|
+
UNLOADED = 0,
|
|
647
|
+
/**
|
|
648
|
+
* The source is currently loading.
|
|
649
|
+
*/
|
|
650
|
+
LOADING = 1,
|
|
651
|
+
/**
|
|
652
|
+
* The source is loaded.
|
|
653
|
+
*/
|
|
654
|
+
LOADED = 2
|
|
655
|
+
}
|
|
656
|
+
/**
|
|
657
|
+
* Represents a source configuration that be loaded into a player instance.
|
|
658
|
+
*/
|
|
659
|
+
interface SourceConfig extends NativeInstanceConfig {
|
|
660
|
+
/**
|
|
661
|
+
* The url for this source configuration.
|
|
662
|
+
*/
|
|
663
|
+
url: string;
|
|
664
|
+
/**
|
|
665
|
+
* The `SourceType` for this configuration.
|
|
666
|
+
*/
|
|
667
|
+
type?: SourceType;
|
|
668
|
+
/**
|
|
669
|
+
* The title of the video source.
|
|
670
|
+
*/
|
|
671
|
+
title?: string;
|
|
672
|
+
/**
|
|
673
|
+
* The URL to a preview image displayed until the video starts.
|
|
674
|
+
*/
|
|
675
|
+
poster?: string;
|
|
676
|
+
/**
|
|
677
|
+
* Indicates whether to show the poster image during playback.
|
|
678
|
+
* Useful, for example, for audio-only streams.
|
|
679
|
+
*/
|
|
680
|
+
isPosterPersistent?: boolean;
|
|
681
|
+
/**
|
|
682
|
+
* The DRM config for the source.
|
|
683
|
+
*/
|
|
684
|
+
drmConfig?: DrmConfig;
|
|
685
|
+
/**
|
|
686
|
+
* External subtitle tracks to be added into the player.
|
|
687
|
+
*/
|
|
688
|
+
subtitleTracks?: SideLoadedSubtitleTrack[];
|
|
689
|
+
}
|
|
690
|
+
/**
|
|
691
|
+
* Represents audio and video content that can be loaded into a player.
|
|
692
|
+
*/
|
|
693
|
+
declare class Source extends NativeInstance<SourceConfig> {
|
|
694
|
+
/**
|
|
695
|
+
* The native DRM config reference of this source.
|
|
696
|
+
*/
|
|
697
|
+
drm?: Drm;
|
|
698
|
+
/**
|
|
699
|
+
* Whether the native `Source` object has been created.
|
|
700
|
+
*/
|
|
701
|
+
isInitialized: boolean;
|
|
702
|
+
/**
|
|
703
|
+
* Whether the native `Source` object has been disposed.
|
|
704
|
+
*/
|
|
705
|
+
isDestroyed: boolean;
|
|
706
|
+
/**
|
|
707
|
+
* Allocates the native `Source` instance and its resources natively.
|
|
708
|
+
*/
|
|
709
|
+
initialize: () => void;
|
|
710
|
+
/**
|
|
711
|
+
* Destroys the native `Source` and releases all of its allocated resources.
|
|
712
|
+
*/
|
|
713
|
+
destroy: () => void;
|
|
714
|
+
/**
|
|
715
|
+
* The duration of the source in seconds if it’s a VoD or `INFINITY` if it’s a live stream.
|
|
716
|
+
* Default value is `0` if the duration is not available or not known.
|
|
717
|
+
*/
|
|
718
|
+
duration: () => Promise<number>;
|
|
719
|
+
/**
|
|
720
|
+
* Whether the source is currently active in a player (i.e. playing back or paused).
|
|
721
|
+
* Only one source can be active in the same player instance at any time.
|
|
722
|
+
*/
|
|
723
|
+
isActive: () => Promise<boolean>;
|
|
724
|
+
/**
|
|
725
|
+
* Whether the source is currently attached to a player instance.
|
|
726
|
+
*/
|
|
727
|
+
isAttachedToPlayer: () => Promise<boolean>;
|
|
728
|
+
/**
|
|
729
|
+
* Metadata for the currently loaded source.
|
|
730
|
+
*/
|
|
731
|
+
metadata: () => Promise<Record<string, any> | null>;
|
|
732
|
+
/**
|
|
733
|
+
* Set metadata for the currently loaded source.
|
|
734
|
+
* Setting the metadata to `null` clears the metadata object in native source.
|
|
735
|
+
*/
|
|
736
|
+
setMetadata: (metadata: Record<string, any> | null) => void;
|
|
737
|
+
/**
|
|
738
|
+
* The current `LoadingState` of the source.
|
|
739
|
+
*/
|
|
740
|
+
loadingState: () => Promise<LoadingState>;
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
/**
|
|
744
|
+
* Object used to configure a new `Player` instance.
|
|
745
|
+
*/
|
|
746
|
+
interface PlayerConfig extends NativeInstanceConfig {
|
|
747
|
+
/**
|
|
748
|
+
* Bitmovin license key that can be found in the Bitmovin portal.
|
|
749
|
+
* If a license key is set here, it will be used instead of the license key found in the `Info.plist` and `AndroidManifest.xml`.
|
|
750
|
+
* @example
|
|
751
|
+
* Configuring the player license key from source code:
|
|
752
|
+
* ```
|
|
753
|
+
* const player = new Player({
|
|
754
|
+
* licenseKey: '\<LICENSE-KEY-CODE\>',
|
|
755
|
+
* });
|
|
756
|
+
* ```
|
|
757
|
+
* @example
|
|
758
|
+
* `licenseKey` can be safely omitted from source code if it has
|
|
759
|
+
* been configured in Info.plist/AndroidManifest.xml.
|
|
760
|
+
* ```
|
|
761
|
+
* const player = new Player(); // omit `licenseKey`
|
|
762
|
+
* player.play(); // call methods and properties...
|
|
763
|
+
* ```
|
|
764
|
+
*/
|
|
765
|
+
licenseKey?: string;
|
|
766
|
+
}
|
|
767
|
+
/**
|
|
768
|
+
* Loads, controls and renders audio and video content represented through `Source`s. A player
|
|
769
|
+
* instance can be created via the `usePlayer` hook and will idle until one or more `Source`s are
|
|
770
|
+
* loaded. Once `load` is called, the player becomes active and initiates necessary downloads to
|
|
771
|
+
* start playback of the loaded source(s).
|
|
772
|
+
*
|
|
773
|
+
* Can be attached to `PlayerView` component in order to use Bitmovin's Player Web UI.
|
|
774
|
+
* @see PlayerView
|
|
775
|
+
*/
|
|
776
|
+
declare class Player extends NativeInstance<PlayerConfig> {
|
|
777
|
+
/**
|
|
778
|
+
* Currently active source, or `null` if none is active.
|
|
779
|
+
*/
|
|
780
|
+
source?: Source;
|
|
781
|
+
/**
|
|
782
|
+
* Whether the native `Player` object has been created.
|
|
783
|
+
*/
|
|
784
|
+
isInitialized: boolean;
|
|
785
|
+
/**
|
|
786
|
+
* Whether the native `Player` object has been disposed.
|
|
787
|
+
*/
|
|
788
|
+
isDestroyed: boolean;
|
|
789
|
+
/**
|
|
790
|
+
* Allocates the native `Player` instance and its resources natively.
|
|
791
|
+
*/
|
|
792
|
+
initialize: () => void;
|
|
793
|
+
/**
|
|
794
|
+
* Destroys the native `Player` and releases all of its allocated resources.
|
|
795
|
+
*/
|
|
796
|
+
destroy: () => void;
|
|
797
|
+
/**
|
|
798
|
+
* Loads a new `Source` from `sourceConfig` into the player.
|
|
799
|
+
*/
|
|
800
|
+
load: (sourceConfig: SourceConfig) => void;
|
|
801
|
+
/**
|
|
802
|
+
* Loads the given `Source` into the player.
|
|
803
|
+
*/
|
|
804
|
+
loadSource: (source: Source) => void;
|
|
805
|
+
/**
|
|
806
|
+
* Unloads all `Source`s from the player.
|
|
807
|
+
*/
|
|
808
|
+
unload: () => void;
|
|
809
|
+
/**
|
|
810
|
+
* Starts or resumes playback after being paused. Has no effect if the player is already playing.
|
|
811
|
+
*/
|
|
812
|
+
play: () => void;
|
|
813
|
+
/**
|
|
814
|
+
* Pauses the video if it is playing. Has no effect if the player is already paused.
|
|
815
|
+
*/
|
|
816
|
+
pause: () => void;
|
|
817
|
+
/**
|
|
818
|
+
* Seeks to the given playback time specified by the parameter `time` in seconds. Must not be
|
|
819
|
+
* greater than the total duration of the video. Has no effect when watching a live stream since
|
|
820
|
+
* seeking is not possible.
|
|
821
|
+
*
|
|
822
|
+
* @param time - The time to seek to in seconds.
|
|
823
|
+
*/
|
|
824
|
+
seek: (time: number) => void;
|
|
825
|
+
/**
|
|
826
|
+
* Mutes the player if an audio track is available. Has no effect if the player is already muted.
|
|
827
|
+
*/
|
|
828
|
+
mute: () => void;
|
|
829
|
+
/**
|
|
830
|
+
* Unmutes the player if it is muted. Has no effect if the player is already unmuted.
|
|
831
|
+
*/
|
|
832
|
+
unmute: () => void;
|
|
833
|
+
/**
|
|
834
|
+
* Sets the player's volume between 0 (silent) and 100 (max volume).
|
|
835
|
+
*
|
|
836
|
+
* @param volume - The volume level to set.
|
|
837
|
+
*/
|
|
838
|
+
setVolume: (volume: number) => void;
|
|
839
|
+
/**
|
|
840
|
+
* @returns The player's current volume level.
|
|
841
|
+
*/
|
|
842
|
+
getVolume: () => Promise<number>;
|
|
843
|
+
/**
|
|
844
|
+
* @returns The current playback time in seconds.
|
|
845
|
+
*
|
|
846
|
+
* For VoD streams the returned time ranges between 0 and the duration of the asset.
|
|
847
|
+
*
|
|
848
|
+
* For live streams it can be specified if an absolute UNIX timestamp or a value
|
|
849
|
+
* relative to the playback start should be returned.
|
|
850
|
+
*
|
|
851
|
+
* @param mode - The time mode to specify: an absolute UNIX timestamp ('absolute') or relative time ('relative').
|
|
852
|
+
*/
|
|
853
|
+
getCurrentTime: (mode?: "relative" | "absolute" | undefined) => Promise<number>;
|
|
854
|
+
/**
|
|
855
|
+
* @returns The total duration in seconds of the current video or INFINITY if it’s a live stream.
|
|
856
|
+
*/
|
|
857
|
+
getDuration: () => Promise<number>;
|
|
858
|
+
/**
|
|
859
|
+
* @returns `true` if the player is muted.
|
|
860
|
+
*/
|
|
861
|
+
isMuted: () => Promise<boolean>;
|
|
862
|
+
/**
|
|
863
|
+
* @returns `true` if the player is currently playing, i.e. has started and is not paused.
|
|
864
|
+
*/
|
|
865
|
+
isPlaying: () => Promise<boolean>;
|
|
866
|
+
/**
|
|
867
|
+
* @returns `true` if the player has started playback but it's currently paused.
|
|
868
|
+
*/
|
|
869
|
+
isPaused: () => Promise<boolean>;
|
|
870
|
+
/**
|
|
871
|
+
* @returns `true` if the displayed video is a live stream.
|
|
872
|
+
*/
|
|
873
|
+
isLive: () => Promise<boolean>;
|
|
874
|
+
/**
|
|
875
|
+
* @remarks Only available for iOS devices.
|
|
876
|
+
* @returns `true` when media is played externally using AirPlay.
|
|
877
|
+
*/
|
|
878
|
+
isAirPlayActive: () => Promise<boolean>;
|
|
879
|
+
/**
|
|
880
|
+
* @remarks Only available for iOS devices.
|
|
881
|
+
* @returns `true` when AirPlay is available.
|
|
882
|
+
*/
|
|
883
|
+
isAirPlayAvailable: () => Promise<boolean>;
|
|
884
|
+
/**
|
|
885
|
+
* @returns An array containing SubtitleTrack objects for all available subtitle tracks.
|
|
886
|
+
*/
|
|
887
|
+
getAvailableSubtitles: () => Promise<SubtitleTrack[]>;
|
|
888
|
+
}
|
|
889
|
+
|
|
890
|
+
/**
|
|
462
891
|
* Base `PlayerView` component props. Used to stablish common
|
|
463
892
|
* props between `NativePlayerView` and `PlayerView`.
|
|
464
893
|
* @see NativePlayerView
|
|
@@ -483,4 +912,10 @@ interface PlayerViewProps extends BasePlayerViewProps, PlayerViewEvents {
|
|
|
483
912
|
*/
|
|
484
913
|
declare function PlayerView(props: PlayerViewProps): JSX.Element;
|
|
485
914
|
|
|
486
|
-
|
|
915
|
+
/**
|
|
916
|
+
* React hook that creates and returns a reference to a `Player` instance
|
|
917
|
+
* that can be used inside any component.
|
|
918
|
+
*/
|
|
919
|
+
declare function usePlayer(config?: PlayerConfig): Player;
|
|
920
|
+
|
|
921
|
+
export { BasePlayerViewProps, DestroyEvent, Drm, DrmConfig, ErrorEvent, Event, EventSource, FairplayConfig, LoadingState, MutedEvent, PausedEvent, PlayEvent, PlaybackFinishedEvent, Player, PlayerActiveEvent, PlayerConfig, PlayerErrorEvent, PlayerView, PlayerViewProps, PlayerWarningEvent, PlayingEvent, ReadyEvent, SeekEvent, SeekedEvent, SideLoadedSubtitleTrack, Source, SourceConfig, SourceErrorEvent, SourceLoadEvent, SourceLoadedEvent, SourceType, SourceUnloadedEvent, SourceWarningEvent, SubtitleAddedEvent, SubtitleChangedEvent, SubtitleFormat, SubtitleRemovedEvent, SubtitleTrack, TimeChangedEvent, UnmutedEvent, WidevineConfig, usePlayer };
|