react-native-theoplayer 3.0.2 → 3.2.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/CHANGELOG.md +22 -0
- package/android/src/main/AndroidManifest.xml +1 -1
- package/android/src/main/java/com/theoplayer/PlayerConfigAdapter.kt +4 -0
- package/android/src/main/java/com/theoplayer/PlayerEventEmitter.kt +5 -0
- package/android/src/main/java/com/theoplayer/ReactTHEOplayerContext.kt +4 -29
- package/android/src/main/java/com/theoplayer/player/PlayerModule.kt +8 -0
- package/android/src/main/java/com/theoplayer/track/TrackListAdapter.kt +47 -2
- package/ios/THEOplayerRCTNetworkUtils.swift +3 -1
- package/ios/THEOplayerRCTTextTrackEventHandler.swift +21 -17
- package/ios/THEOplayerRCTTrackMetadataAggregator.swift +64 -8
- package/ios/THEOplayerRCTView.swift +4 -0
- package/ios/contentprotection/THEOplayerRCTContentProtectionAPI.swift +4 -0
- package/lib/commonjs/api/config/PlayerConfiguration.js.map +1 -1
- package/lib/commonjs/api/track/DateRangeCue.js +19 -0
- package/lib/commonjs/api/track/DateRangeCue.js.map +1 -0
- package/lib/commonjs/api/track/TextTrack.js +2 -0
- package/lib/commonjs/api/track/TextTrack.js.map +1 -1
- package/lib/commonjs/api/track/barrel.js +11 -0
- package/lib/commonjs/api/track/barrel.js.map +1 -1
- package/lib/commonjs/internal/THEOplayerView.js +17 -2
- package/lib/commonjs/internal/THEOplayerView.js.map +1 -1
- package/lib/commonjs/internal/adapter/THEOplayerAdapter.js +9 -3
- package/lib/commonjs/internal/adapter/THEOplayerAdapter.js.map +1 -1
- package/lib/commonjs/internal/adapter/WebEventForwarder.js +3 -0
- package/lib/commonjs/internal/adapter/WebEventForwarder.js.map +1 -1
- package/lib/commonjs/internal/adapter/web/TrackUtils.js +17 -1
- package/lib/commonjs/internal/adapter/web/TrackUtils.js.map +1 -1
- package/lib/module/api/config/PlayerConfiguration.js.map +1 -1
- package/lib/module/api/track/DateRangeCue.js +13 -0
- package/lib/module/api/track/DateRangeCue.js.map +1 -0
- package/lib/module/api/track/TextTrack.js +2 -0
- package/lib/module/api/track/TextTrack.js.map +1 -1
- package/lib/module/api/track/barrel.js +1 -0
- package/lib/module/api/track/barrel.js.map +1 -1
- package/lib/module/internal/THEOplayerView.js +18 -2
- package/lib/module/internal/THEOplayerView.js.map +1 -1
- package/lib/module/internal/adapter/THEOplayerAdapter.js +9 -3
- package/lib/module/internal/adapter/THEOplayerAdapter.js.map +1 -1
- package/lib/module/internal/adapter/WebEventForwarder.js +4 -1
- package/lib/module/internal/adapter/WebEventForwarder.js.map +1 -1
- package/lib/module/internal/adapter/web/TrackUtils.js +16 -1
- package/lib/module/internal/adapter/web/TrackUtils.js.map +1 -1
- package/lib/typescript/api/config/PlayerConfiguration.d.ts +4 -0
- package/lib/typescript/api/track/DateRangeCue.d.ts +61 -0
- package/lib/typescript/api/track/TextTrack.d.ts +4 -1
- package/lib/typescript/api/track/barrel.d.ts +1 -0
- package/lib/typescript/internal/THEOplayerView.d.ts +2 -1
- package/lib/typescript/internal/adapter/web/TrackUtils.d.ts +2 -1
- package/package.json +1 -1
- package/src/api/config/PlayerConfiguration.ts +5 -0
- package/src/api/track/DateRangeCue.ts +74 -0
- package/src/api/track/TextTrack.ts +3 -0
- package/src/api/track/barrel.ts +1 -0
- package/src/internal/THEOplayerView.tsx +19 -3
- package/src/internal/adapter/THEOplayerAdapter.ts +6 -3
- package/src/internal/adapter/WebEventForwarder.ts +5 -0
- package/src/internal/adapter/web/TrackUtils.ts +18 -1
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type { TextTrackCue } from './TextTrackCue';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Represents a cue of a HLS date range metadata text track.
|
|
5
|
+
*
|
|
6
|
+
* @public
|
|
7
|
+
*/
|
|
8
|
+
export interface DateRangeCue extends TextTrackCue {
|
|
9
|
+
/**
|
|
10
|
+
* The class of the date range cue.
|
|
11
|
+
*
|
|
12
|
+
* @remarks
|
|
13
|
+
* <br/> - The class is a client-defined string specifying a set of attributes with associated value semantics.
|
|
14
|
+
*/
|
|
15
|
+
class: string | undefined;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The playback position at which the date range cue becomes active, as a Date.
|
|
19
|
+
*/
|
|
20
|
+
startDate: Date;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* The playback position at which the date range cue becomes inactive, as a Date.
|
|
24
|
+
*/
|
|
25
|
+
endDate: Date | undefined;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* The duration of the date range cue, in milliseconds.
|
|
29
|
+
*/
|
|
30
|
+
duration: number | undefined;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* The planned duration of the date range cue, in milliseconds.
|
|
34
|
+
*
|
|
35
|
+
* @remarks
|
|
36
|
+
* <br/> - This is used when the exact duration is not known yet.
|
|
37
|
+
*/
|
|
38
|
+
plannedDuration: number | undefined;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Whether end-on-next is enabled for the date range cue.
|
|
42
|
+
*
|
|
43
|
+
* @remarks
|
|
44
|
+
* <br/> - End-on-next results in the {@link DateRangeCue.endDate} of the date range cue becoming equal to the {@link DateRangeCue.startDate} of the next date range cue with the same {@link DateRangeCue."class"}, once it is known.
|
|
45
|
+
*/
|
|
46
|
+
endOnNext: boolean;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* The SCTE 'cmd' splice_info_section of the date range cue.
|
|
50
|
+
*/
|
|
51
|
+
scte35Cmd: ArrayBuffer | undefined;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* The SCTE 'out' splice_info_section of the date range cue.
|
|
55
|
+
*/
|
|
56
|
+
scte35Out: ArrayBuffer | undefined;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* The SCTE 'in' splice_info_section of the date range cue.
|
|
60
|
+
*/
|
|
61
|
+
scte35In: ArrayBuffer | undefined;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Custom attributes extracted from the cue source.
|
|
65
|
+
*/
|
|
66
|
+
customAttributes: Record<string, string | number | ArrayBuffer>;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Check whether a text track cue is of type DateRangeCue.
|
|
71
|
+
*/
|
|
72
|
+
export function isDateRangeCue(cue: TextTrackCue): cue is DateRangeCue {
|
|
73
|
+
return (cue as DateRangeCue).customAttributes != undefined;
|
|
74
|
+
}
|
|
@@ -7,6 +7,8 @@ export enum TextTrackType {
|
|
|
7
7
|
srt = 'srt',
|
|
8
8
|
ttml = 'ttml',
|
|
9
9
|
webvtt = 'webvtt',
|
|
10
|
+
daterange = 'daterange',
|
|
11
|
+
eventstream = 'eventstream',
|
|
10
12
|
}
|
|
11
13
|
|
|
12
14
|
export enum TextTrackKind {
|
|
@@ -65,6 +67,7 @@ export interface TextTrack extends Track {
|
|
|
65
67
|
* The mode of the text track, represented by a value from the following list:
|
|
66
68
|
* <br/> - `'disabled'`: The track is disabled.
|
|
67
69
|
* <br/> - `'showing'`: The track is showing.
|
|
70
|
+
* <br/> - `'hidden'`: The track is enabled and loading cues, but not shown. (used for metadata tracks)
|
|
68
71
|
*/
|
|
69
72
|
mode: TextTrackMode;
|
|
70
73
|
|
package/src/api/track/barrel.ts
CHANGED
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
View,
|
|
12
12
|
ViewStyle,
|
|
13
13
|
} from 'react-native';
|
|
14
|
-
import
|
|
14
|
+
import { isDateRangeCue, PlayerConfiguration, PlayerError, TextTrackCue, THEOplayerViewProps } from 'react-native-theoplayer';
|
|
15
15
|
import { CastEventType, PlayerEventType } from 'react-native-theoplayer';
|
|
16
16
|
|
|
17
17
|
import styles from './THEOplayerView.style';
|
|
@@ -254,12 +254,28 @@ export class THEOplayerView extends PureComponent<React.PropsWithChildren<THEOpl
|
|
|
254
254
|
const nativeEvent = event.nativeEvent;
|
|
255
255
|
const cue = nativeEvent.cue;
|
|
256
256
|
if (cue) {
|
|
257
|
-
|
|
258
|
-
cue.endTime = decodeNanInf(cue.endTime);
|
|
257
|
+
this.normalizeCue(cue);
|
|
259
258
|
}
|
|
260
259
|
this._facade.dispatchEvent(new DefaultTextTrackEvent(toTextTrackEventType(nativeEvent.type), nativeEvent.trackUid, cue));
|
|
261
260
|
};
|
|
262
261
|
|
|
262
|
+
private normalizeCue(cue: TextTrackCue) {
|
|
263
|
+
cue.startTime = decodeNanInf(cue.startTime);
|
|
264
|
+
cue.endTime = decodeNanInf(cue.endTime);
|
|
265
|
+
if (isDateRangeCue(cue)) {
|
|
266
|
+
cue.startDate = new Date(cue.startDate);
|
|
267
|
+
if (cue.endDate) {
|
|
268
|
+
cue.endDate = new Date(cue.endDate);
|
|
269
|
+
}
|
|
270
|
+
if (cue.duration) {
|
|
271
|
+
cue.duration = decodeNanInf(cue.duration);
|
|
272
|
+
}
|
|
273
|
+
if (cue.plannedDuration) {
|
|
274
|
+
cue.plannedDuration = decodeNanInf(cue.plannedDuration);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
|
|
263
279
|
private _onMediaTrackListEvent = (event: NativeSyntheticEvent<NativeMediaTrackListEvent>) => {
|
|
264
280
|
const nativeEvent = event.nativeEvent;
|
|
265
281
|
this._facade.dispatchEvent(
|
|
@@ -142,6 +142,9 @@ export class THEOplayerAdapter extends DefaultEventDispatcher<PlayerEventMap> im
|
|
|
142
142
|
this._state.selectedAudioTrack = event.selectedAudioTrack;
|
|
143
143
|
this._state.selectedVideoTrack = event.selectedVideoTrack;
|
|
144
144
|
this._state.selectedTextTrack = event.selectedTextTrack;
|
|
145
|
+
if (isFinite(this._state.duration)) {
|
|
146
|
+
this._state.seekable = [{start: 0, end: this._state.duration}];
|
|
147
|
+
}
|
|
145
148
|
};
|
|
146
149
|
|
|
147
150
|
private onDurationChange = (event: DurationChangeEvent) => {
|
|
@@ -388,7 +391,7 @@ export class THEOplayerAdapter extends DefaultEventDispatcher<PlayerEventMap> im
|
|
|
388
391
|
return;
|
|
389
392
|
}
|
|
390
393
|
this._state.selectedAudioTrack = trackUid;
|
|
391
|
-
NativeModules.PlayerModule.setSelectedAudioTrack(this._view.nativeHandle, trackUid
|
|
394
|
+
NativeModules.PlayerModule.setSelectedAudioTrack(this._view.nativeHandle, (trackUid !== undefined) ? trackUid : -1);
|
|
392
395
|
}
|
|
393
396
|
|
|
394
397
|
get videoTracks(): MediaTrack[] {
|
|
@@ -405,7 +408,7 @@ export class THEOplayerAdapter extends DefaultEventDispatcher<PlayerEventMap> im
|
|
|
405
408
|
}
|
|
406
409
|
this._state.selectedVideoTrack = trackUid;
|
|
407
410
|
this._state.targetVideoQuality = undefined;
|
|
408
|
-
NativeModules.PlayerModule.setSelectedVideoTrack(this._view.nativeHandle, trackUid
|
|
411
|
+
NativeModules.PlayerModule.setSelectedVideoTrack(this._view.nativeHandle, (trackUid !== undefined) ? trackUid : -1);
|
|
409
412
|
}
|
|
410
413
|
|
|
411
414
|
get textTracks(): TextTrack[] {
|
|
@@ -428,7 +431,7 @@ export class THEOplayerAdapter extends DefaultEventDispatcher<PlayerEventMap> im
|
|
|
428
431
|
track.mode = TextTrackMode.disabled;
|
|
429
432
|
}
|
|
430
433
|
});
|
|
431
|
-
NativeModules.PlayerModule.setSelectedTextTrack(this._view.nativeHandle, trackUid
|
|
434
|
+
NativeModules.PlayerModule.setSelectedTextTrack(this._view.nativeHandle, (trackUid !== undefined) ? trackUid : -1);
|
|
432
435
|
}
|
|
433
436
|
|
|
434
437
|
get textTrackStyle(): TextTrackStyle {
|
|
@@ -26,6 +26,8 @@ import {
|
|
|
26
26
|
PlayerEventType,
|
|
27
27
|
PresentationMode,
|
|
28
28
|
TextTrackEventType,
|
|
29
|
+
TextTrackKind,
|
|
30
|
+
TextTrackMode,
|
|
29
31
|
TrackListEventType,
|
|
30
32
|
} from 'react-native-theoplayer';
|
|
31
33
|
import type { THEOplayerWebAdapter } from './THEOplayerWebAdapter';
|
|
@@ -251,6 +253,9 @@ export class WebEventForwarder {
|
|
|
251
253
|
|
|
252
254
|
private readonly onAddTextTrack = (event: AddTrackEvent) => {
|
|
253
255
|
const track = event.track as NativeTextTrack;
|
|
256
|
+
if (track.kind === TextTrackKind.metadata) {
|
|
257
|
+
track.mode = TextTrackMode.hidden;
|
|
258
|
+
}
|
|
254
259
|
track.addEventListener('addcue', this.onAddTextTrackCue(track));
|
|
255
260
|
track.addEventListener('removecue', this.onRemoveTextTrackCue(track));
|
|
256
261
|
track.addEventListener('entercue', this.onEnterTextTrackCue(track));
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type {
|
|
2
|
+
DateRangeCue as NativeDateRangeCue,
|
|
2
3
|
MediaTrack as NativeMediaTrack,
|
|
3
4
|
MediaTrackList as NativeMediaTrackList,
|
|
4
5
|
Quality as NativeQuality,
|
|
@@ -6,9 +7,13 @@ import type {
|
|
|
6
7
|
TextTrackCue as NativeTextTrackCue,
|
|
7
8
|
TextTracksList as NativeTextTrackList,
|
|
8
9
|
} from 'theoplayer';
|
|
9
|
-
import type { MediaTrack, TextTrack, TextTrackCue } from 'react-native-theoplayer';
|
|
10
|
+
import type { MediaTrack, TextTrack, TextTrackCue, DateRangeCue } from 'react-native-theoplayer';
|
|
10
11
|
import { decodeNanInf } from '../../utils/TypeUtils';
|
|
11
12
|
|
|
13
|
+
export function isDateRangeCue(cue: TextTrackCue): cue is DateRangeCue {
|
|
14
|
+
return (cue as NativeDateRangeCue).customAttributes != undefined;
|
|
15
|
+
}
|
|
16
|
+
|
|
12
17
|
export function fromNativeCue(cue: NativeTextTrackCue): TextTrackCue {
|
|
13
18
|
return {
|
|
14
19
|
id: cue.id,
|
|
@@ -16,6 +21,18 @@ export function fromNativeCue(cue: NativeTextTrackCue): TextTrackCue {
|
|
|
16
21
|
startTime: decodeNanInf(1e3 * cue.startTime),
|
|
17
22
|
endTime: decodeNanInf(1e3 * cue.endTime),
|
|
18
23
|
content: cue.content,
|
|
24
|
+
...(isDateRangeCue(cue) && {
|
|
25
|
+
class: cue.class,
|
|
26
|
+
startDate: cue.startDate,
|
|
27
|
+
endDate: cue.endDate,
|
|
28
|
+
duration: cue.duration ? decodeNanInf(1e3 * cue.duration) : cue.duration,
|
|
29
|
+
plannedDuration: cue.plannedDuration ? decodeNanInf(1e3 * cue.plannedDuration) : cue.plannedDuration,
|
|
30
|
+
endOnNext: cue.endOnNext,
|
|
31
|
+
scte35Cmd: cue.scte35Cmd,
|
|
32
|
+
scte35Out: cue.scte35Out,
|
|
33
|
+
scte35In: cue.scte35In,
|
|
34
|
+
customAttributes: cue.customAttributes,
|
|
35
|
+
}),
|
|
19
36
|
} as TextTrackCue;
|
|
20
37
|
}
|
|
21
38
|
|