forked from THEOplayer/react-native-theoplayer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
THEOplayerView.ts
273 lines (229 loc) · 6.83 KB
/
THEOplayerView.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
import type { SourceDescription } from './source/SourceDescription';
import type { StyleProp, ViewStyle } from 'react-native';
import type {
DurationChangeEvent,
ErrorEvent,
LoadedMetadataEvent,
ReadyStateChangeEvent,
TimeUpdateEvent,
ProgressEvent,
SegmentNotFoundEvent,
} from './event/PlayerEvent';
import type { MediaTrackEvent, MediaTrackListEvent, TextTrackEvent, TextTrackListEvent } from './event/TrackEvent';
import type { PlayerConfiguration } from './config/PlayerConfiguration';
import type { ABRConfiguration } from './abr/ABRConfiguration';
import type { AdEvent } from './event/AdEvent';
import type { AdsAPI } from './ads/AdsAPI';
import type { CastAPI } from './cast/CastAPI';
import type { CastEvent } from './event/CastEvent';
export interface THEOplayerViewProps {
/**
* The player configuration with THEOplayer license.
*/
config?: PlayerConfiguration;
/**
* The player's adaptive bitrate (ABR) configuration.
*
* @remarks
* <br/> - This property is supported on Android & Web platforms only.
*/
abrConfig?: ABRConfiguration;
/**
* A source description that determines the current media resource.
*/
source: SourceDescription;
/**
* Used to set the player's paused state.
*
* @remarks
* <br/> - If paused is initially set to `true`, play-out will start once the source is set.
*/
paused?: boolean;
/**
* Used to set the playback rate of the media.
*
* @example
* <br/> - `playbackRate = 0.70` will slow down the playback rate of the media by 30%.
* <br/> - `playbackRate = 1.25` will speed up the playback rate of the media by 25%.
*
* @remarks
* <br/> - Playback rate is represented by a number where `1` is default playback speed.
* <br/> - Playback rate must be a positive number.
* <br/> - It is recommended that you limit the range to between 0.5 and 4.
*/
playbackRate?: number;
/**
* Used to set the volume of the audio.
*
* @remarks
* <br/> - Volume is represented by a floating point number between `0.0` and `1.0`.
*/
volume?: number;
/**
* Determines whether audio is muted.
*/
muted?: boolean;
/**
* Determines whether the player is currently playing in fullscreen.
*/
fullscreen?: boolean;
/**
* Used to set the current selected text track by passing its `uid`, or `null` to select none.
*/
selectedTextTrack?: number | null;
/**
* Used to set the current selected video track by passing its `uid`, or `null` to select none.
*/
selectedVideoTrack?: number | null;
/**
* Used to set the current selected video quality by passing its `uid`, or `null` to select none.
*/
targetVideoQuality?: number | number[] | undefined;
/**
* Used to set the current selected audio track by passing its `uid`, or `null` to select none.
*/
selectedAudioTrack?: number | null;
/**
* The style applied to the player view.
*/
style?: StyleProp<ViewStyle>;
/**
* Invoked before the player goes to fullscreen.
*/
onFullscreenPlayerWillPresent?: () => void;
/**
* Invoked after the player went to fullscreen.
*/
onFullscreenPlayerDidPresent?: () => void;
/**
* Invoked before the player returns from fullscreen.
*/
onFullscreenPlayerWillDismiss?: () => void;
/**
* Invoked after the player returned from fullscreen.
*/
onFullscreenPlayerDidDismiss?: () => void;
/**
* Invoked when the player's buffering state has changed.
*
* @remarks
* <br/> - The `isBuffering` value is typically coupled to showing/hiding a loading indicator.
*
* @param isBuffering A value that indicates whether the player is buffering.
*/
onBufferingStateChange?: (isBuffering: boolean) => void;
/**
* Invoked when the player receives a new source description.
*/
onSourceChange?: () => void;
/**
* Invoked when the player starts loading the manifest.
*/
onLoadStart?: () => void;
/**
* Invoked when the player has determined the duration and dimensions of the
* media resource, and the text and media tracks are ready.
*/
onLoadedMetadata?: (event: LoadedMetadataEvent) => void;
/**
* Invoked when the player can render the media data at the current playback position for the first time.
*/
onLoadedData?: () => void;
/**
* Invoked when the player's readyState has changed.
*/
onReadyStateChange?: (event: ReadyStateChangeEvent) => void;
/**
* Invoked when the player is stalling.
*/
onWaiting?: () => void;
/**
* Invoked when an error occurs.
*/
onError?: (event: ErrorEvent) => void;
/**
* Invoked each time the player has loaded media data.
*/
onProgress?: (event: ProgressEvent) => void;
/**
* Invoked when the player's internal paused state changes to `false`.
*/
onPlay?: () => void;
/**
* Invoked when playback is ready to start after having been paused or delayed due to
* lack of media data.
*/
onPlaying?: () => void;
/**
* Invoked when the player's internal paused state changes to `true`.
*/
onPause?: () => void;
/**
* Invoked when a seek operation starts and the player is seeking a new position.
*/
onSeeking?: () => void;
/**
* Invoked when a seek operation completed and the current playback position has changed.
*/
onSeeked?: () => void;
/**
* Invoked when playback has stopped because the end of the media was reached or because
* no further data is available.
*/
onEnded?: () => void;
/**
* Invoked each time the current playback position changed.
*/
onTimeUpdate?: (event: TimeUpdateEvent) => void;
/**
* Invoked when the player's duration attribute has been updated.
*/
onDurationChange?: (event: DurationChangeEvent) => void;
/**
* Invoked when a segment can not be found.
*
* @remarks
* <br/> - Only dispatched on DASH streams.
*/
onSegmentNotFound?: (event: SegmentNotFoundEvent) => void;
/**
* Invoked when a text track list event occurs.
*/
onTextTrackListEvent?: (event: TextTrackListEvent) => void;
/**
* Invoked when a text track event occurs.
*/
onTextTrackEvent?: (event: TextTrackEvent) => void;
/**
* Invoked when a media track list event occurs.
*/
onMediaTrackListEvent?: (event: MediaTrackListEvent) => void;
/**
* Invoked when a media track event occurs.
*/
onMediaTrackEvent?: (event: MediaTrackEvent) => void;
/**
* Invoked when an ad event occurs.
*/
onAdEvent?: (event: AdEvent) => void;
/**
* Invoked when a cast event occurs, either for Chromecast or Airplay.
*/
onCastEvent?: (event: CastEvent) => void;
}
export interface THEOplayerViewComponent {
/**
* Seek to a new position.
*
* @param seekTime - new time, in milliseconds.
*/
seek: (seekTime: number) => void;
/**
* The API for advertisements.
*/
ads: AdsAPI;
/**
* The API for casting devices.
*/
cast: CastAPI;
}