react-native-theoplayer 2.3.0 → 2.4.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 +19 -0
- package/android/src/main/java/com/theoplayer/presentation/PipUtils.kt +5 -1
- package/android/src/main/java/com/theoplayer/track/TrackListAdapter.kt +3 -2
- package/android/src/main/java/com/theoplayer/util/TypeUtils.kt +6 -6
- package/ios/THEOplayerRCTMainEventHandler.swift +15 -12
- package/ios/THEOplayerRCTTrackMetadataAggregator.swift +2 -2
- package/ios/THEOplayerRCTView.swift +3 -1
- package/ios/backgroundAudio/THEOplayerRCTNowPlayingManager.swift +7 -5
- package/ios/backgroundAudio/THEOplayerRCTView+BackgroundAudioConfig.swift +12 -0
- package/lib/commonjs/api/source/SourceDescription.js.map +1 -1
- package/lib/commonjs/internal/THEOplayerView.js +6 -1
- package/lib/commonjs/internal/THEOplayerView.js.map +1 -1
- package/lib/commonjs/internal/THEOplayerView.web.js +7 -7
- package/lib/commonjs/internal/THEOplayerView.web.js.map +1 -1
- package/lib/commonjs/internal/adapter/THEOplayerAdapter.js +1 -1
- package/lib/commonjs/internal/adapter/THEOplayerAdapter.js.map +1 -1
- package/lib/commonjs/internal/adapter/web/TrackUtils.js +3 -2
- package/lib/commonjs/internal/adapter/web/TrackUtils.js.map +1 -1
- package/lib/commonjs/internal/adapter/web/WebMediaSession.js +17 -29
- package/lib/commonjs/internal/adapter/web/WebMediaSession.js.map +1 -1
- package/lib/commonjs/internal/adapter/web/WebPresentationModeManager.js +1 -1
- package/lib/commonjs/internal/adapter/web/WebPresentationModeManager.js.map +1 -1
- package/lib/module/api/source/SourceDescription.js.map +1 -1
- package/lib/module/internal/THEOplayerView.js +6 -1
- package/lib/module/internal/THEOplayerView.js.map +1 -1
- package/lib/module/internal/THEOplayerView.web.js +7 -7
- package/lib/module/internal/THEOplayerView.web.js.map +1 -1
- package/lib/module/internal/adapter/THEOplayerAdapter.js +1 -1
- package/lib/module/internal/adapter/THEOplayerAdapter.js.map +1 -1
- package/lib/module/internal/adapter/web/TrackUtils.js +3 -2
- package/lib/module/internal/adapter/web/TrackUtils.js.map +1 -1
- package/lib/module/internal/adapter/web/WebMediaSession.js +15 -29
- package/lib/module/internal/adapter/web/WebMediaSession.js.map +1 -1
- package/lib/module/internal/adapter/web/WebPresentationModeManager.js +1 -1
- package/lib/module/internal/adapter/web/WebPresentationModeManager.js.map +1 -1
- package/lib/typescript/api/source/SourceDescription.d.ts +6 -0
- package/lib/typescript/internal/adapter/web/WebMediaSession.d.ts +2 -1
- package/package.json +1 -1
- package/src/api/source/SourceDescription.ts +8 -0
- package/src/internal/THEOplayerView.tsx +6 -1
- package/src/internal/THEOplayerView.web.tsx +4 -7
- package/src/internal/adapter/THEOplayerAdapter.ts +1 -1
- package/src/internal/adapter/web/TrackUtils.ts +3 -2
- package/src/internal/adapter/web/WebMediaSession.ts +14 -29
- package/src/internal/adapter/web/WebPresentationModeManager.ts +1 -1
|
@@ -204,6 +204,12 @@ export interface TextTrackDescription {
|
|
|
204
204
|
* @public
|
|
205
205
|
*/
|
|
206
206
|
export interface BaseSource {
|
|
207
|
+
/**
|
|
208
|
+
* The cross-origin setting of the source.
|
|
209
|
+
*
|
|
210
|
+
* @defaultValue `''`
|
|
211
|
+
*/
|
|
212
|
+
crossOrigin?: CrossOriginSetting;
|
|
207
213
|
/**
|
|
208
214
|
* The URL of a time server used by the player to synchronise the time in DASH sources.
|
|
209
215
|
*
|
|
@@ -25,9 +25,10 @@ export declare class WebMediaSession {
|
|
|
25
25
|
private onAdbreakBegin;
|
|
26
26
|
private onAdbreakEnd;
|
|
27
27
|
private isLive;
|
|
28
|
-
private
|
|
28
|
+
private isInAd;
|
|
29
29
|
private isInBackground;
|
|
30
30
|
private isTrickplayEnabled;
|
|
31
31
|
private isPlayPauseEnabled;
|
|
32
|
+
private isBackgroundAudioEnabled;
|
|
32
33
|
}
|
|
33
34
|
export {};
|
package/package.json
CHANGED
|
@@ -223,6 +223,14 @@ export interface TextTrackDescription {
|
|
|
223
223
|
* @public
|
|
224
224
|
*/
|
|
225
225
|
export interface BaseSource {
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* The cross-origin setting of the source.
|
|
229
|
+
*
|
|
230
|
+
* @defaultValue `''`
|
|
231
|
+
*/
|
|
232
|
+
crossOrigin?: CrossOriginSetting;
|
|
233
|
+
|
|
226
234
|
/**
|
|
227
235
|
* The URL of a time server used by the player to synchronise the time in DASH sources.
|
|
228
236
|
*
|
|
@@ -254,7 +254,12 @@ export class THEOplayerView extends PureComponent<React.PropsWithChildren<THEOpl
|
|
|
254
254
|
|
|
255
255
|
private _onTextTrackEvent = (event: NativeSyntheticEvent<NativeTextTrackEvent>) => {
|
|
256
256
|
const nativeEvent = event.nativeEvent;
|
|
257
|
-
|
|
257
|
+
const cue = nativeEvent.cue;
|
|
258
|
+
if (cue) {
|
|
259
|
+
cue.startTime = decodeNanInf(cue.startTime);
|
|
260
|
+
cue.endTime = decodeNanInf(cue.endTime);
|
|
261
|
+
}
|
|
262
|
+
this._facade.dispatchEvent(new DefaultTextTrackEvent(toTextTrackEventType(nativeEvent.type), nativeEvent.trackUid, cue));
|
|
258
263
|
};
|
|
259
264
|
|
|
260
265
|
private _onMediaTrackListEvent = (event: NativeSyntheticEvent<NativeMediaTrackListEvent>) => {
|
|
@@ -15,21 +15,18 @@ export function THEOplayerView(props: React.PropsWithChildren<THEOplayerViewProp
|
|
|
15
15
|
// Create player inside container.
|
|
16
16
|
if (container.current) {
|
|
17
17
|
const chromeless = config?.chromeless === true || config?.chromeless === undefined;
|
|
18
|
+
const updatedConfig = {...config, allowNativeFullscreen: true};
|
|
18
19
|
if (chromeless) {
|
|
19
|
-
player.current = new THEOplayer.ChromelessPlayer(container.current,
|
|
20
|
+
player.current = new THEOplayer.ChromelessPlayer(container.current, updatedConfig);
|
|
20
21
|
} else {
|
|
21
22
|
player.current = new THEOplayer.Player(container.current, {
|
|
22
|
-
...
|
|
23
|
+
...updatedConfig,
|
|
23
24
|
ui: {
|
|
24
25
|
fluid: true,
|
|
25
|
-
}
|
|
26
|
-
allowNativeFullscreen: true,
|
|
26
|
+
}
|
|
27
27
|
} as THEOplayer.PlayerConfiguration);
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
// Prepare the player to ChromelessPlayer.autoplay on platforms where autoplay is restricted without user action.
|
|
31
|
-
player.current.prepareWithUserAction();
|
|
32
|
-
|
|
33
30
|
// Adapt native player to react-native player.
|
|
34
31
|
adapter.current = new THEOplayerWebAdapter(player.current, config);
|
|
35
32
|
|
|
@@ -372,7 +372,7 @@ export class THEOplayerAdapter extends DefaultEventDispatcher<PlayerEventMap> im
|
|
|
372
372
|
set selectedTextTrack(trackUid: number | undefined) {
|
|
373
373
|
this._state.selectedTextTrack = trackUid;
|
|
374
374
|
this.textTracks.forEach((track) => {
|
|
375
|
-
if (track.uid
|
|
375
|
+
if (track.uid === trackUid) {
|
|
376
376
|
track.mode = TextTrackMode.showing;
|
|
377
377
|
} else if (track.mode === TextTrackMode.showing) {
|
|
378
378
|
track.mode = TextTrackMode.disabled;
|
|
@@ -7,13 +7,14 @@ import type {
|
|
|
7
7
|
TextTracksList as NativeTextTrackList,
|
|
8
8
|
} from 'theoplayer';
|
|
9
9
|
import type { MediaTrack, TextTrack, TextTrackCue } from 'react-native-theoplayer';
|
|
10
|
+
import { decodeNanInf } from '../../utils/TypeUtils';
|
|
10
11
|
|
|
11
12
|
export function fromNativeCue(cue: NativeTextTrackCue): TextTrackCue {
|
|
12
13
|
return {
|
|
13
14
|
id: cue.id,
|
|
14
15
|
uid: cue.uid,
|
|
15
|
-
startTime: 1e3 * cue.startTime,
|
|
16
|
-
endTime: 1e3 * cue.endTime,
|
|
16
|
+
startTime: decodeNanInf(1e3 * cue.startTime),
|
|
17
|
+
endTime: decodeNanInf(1e3 * cue.endTime),
|
|
17
18
|
content: cue.content,
|
|
18
19
|
} as TextTrackCue;
|
|
19
20
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-empty-function */
|
|
2
2
|
import type { ChromelessPlayer } from 'theoplayer';
|
|
3
3
|
import type { THEOplayerWebAdapter } from '../THEOplayerWebAdapter';
|
|
4
|
-
import { PresentationMode } from 'react-native-theoplayer';
|
|
5
4
|
|
|
6
5
|
interface WebMediaSessionConfig {
|
|
7
6
|
skipTime: number;
|
|
@@ -151,43 +150,29 @@ export class WebMediaSession {
|
|
|
151
150
|
return !isFinite(this._player.duration);
|
|
152
151
|
}
|
|
153
152
|
|
|
154
|
-
private
|
|
155
|
-
return this._player.ads?.playing
|
|
153
|
+
private isInAd(): boolean {
|
|
154
|
+
return this._player.ads?.playing === true;
|
|
156
155
|
}
|
|
157
156
|
|
|
158
157
|
private isInBackground(): boolean {
|
|
159
158
|
return document.visibilityState !== 'visible';
|
|
160
159
|
}
|
|
161
160
|
|
|
161
|
+
// By default, only show trick-play buttons if:
|
|
162
|
+
// - backgroundAudio is enabled, or the player is in foreground;
|
|
163
|
+
// - and, the current asset is neither a live stream, nor an ad.
|
|
162
164
|
private isTrickplayEnabled(): boolean {
|
|
163
|
-
|
|
164
|
-
if (this.isLive()) {
|
|
165
|
-
return false;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
// In PiP mode, disable trick-play for ads.
|
|
169
|
-
if (this._webAdapter.presentationMode === PresentationMode.pip) {
|
|
170
|
-
return !this.isAd();
|
|
171
|
-
}
|
|
172
|
-
// During background playback
|
|
173
|
-
if (this.isInBackground()) {
|
|
174
|
-
// Disable trick-play for ads.
|
|
175
|
-
return !(this.isAd() || this.isLive());
|
|
176
|
-
}
|
|
177
|
-
return true;
|
|
165
|
+
return (this.isBackgroundAudioEnabled() || !this.isInBackground()) && !this.isLive() && !this.isInAd();
|
|
178
166
|
}
|
|
179
167
|
|
|
168
|
+
// By default, only show a play/pause button if:
|
|
169
|
+
// - backgroundAudio is enabled, or the player is in foreground;
|
|
170
|
+
// - and, the current asset is not an ad.
|
|
180
171
|
private isPlayPauseEnabled(): boolean {
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
// During background playback
|
|
187
|
-
if (this.isInBackground()) {
|
|
188
|
-
// Disable play/pause for ads & live content.
|
|
189
|
-
return !(this.isAd() || this.isLive());
|
|
190
|
-
}
|
|
191
|
-
return true;
|
|
172
|
+
return (this.isBackgroundAudioEnabled() || !this.isInBackground()) && !this.isInAd();
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
private isBackgroundAudioEnabled(): boolean {
|
|
176
|
+
return this._webAdapter.backgroundAudioConfiguration.enabled === true;
|
|
192
177
|
}
|
|
193
178
|
}
|