react-native-theoplayer 2.2.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 +25 -0
- package/android/src/main/java/com/theoplayer/presentation/PipUtils.kt +248 -0
- package/android/src/main/java/com/theoplayer/presentation/PresentationManager.kt +22 -55
- 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/android/src/main/res/drawable/ic_fast_forward.xml +9 -0
- package/android/src/main/res/drawable/ic_rewind.xml +9 -0
- package/android/src/main/res/values/strings.xml +8 -0
- 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/react-native-theoplayer.podspec +0 -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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["fromNativeCue","cue","id","uid","startTime","endTime","content","fromNativeTextTrackList","tracks","map","track","fromNativeTextTrack","kind","label","language","mode","type","src","forced","cues","fromNativeMediaTrackList","fromNativeMediaTrack","activeQuality","qualities","findNativeQualityByUid","mediaTrack","find","quality","findNativeQualitiesByUid","undefined","Array","isArray","filter","includes"],"sources":["TrackUtils.ts"],"sourcesContent":["import type {\n MediaTrack as NativeMediaTrack,\n MediaTrackList as NativeMediaTrackList,\n Quality as NativeQuality,\n TextTrack as NativeTextTrack,\n TextTrackCue as NativeTextTrackCue,\n TextTracksList as NativeTextTrackList,\n} from 'theoplayer';\nimport type { MediaTrack, TextTrack, TextTrackCue } from 'react-native-theoplayer';\n\nexport function fromNativeCue(cue: NativeTextTrackCue): TextTrackCue {\n return {\n id: cue.id,\n uid: cue.uid,\n startTime: 1e3 * cue.startTime,\n endTime: 1e3 * cue.endTime,\n content: cue.content,\n } as TextTrackCue;\n}\n\nexport function fromNativeTextTrackList(tracks: NativeTextTrackList): TextTrack[] {\n return tracks.map((track) => fromNativeTextTrack(track));\n}\n\nexport function fromNativeTextTrack(track: NativeTextTrack): TextTrack {\n const { id, uid, kind, label, language, mode, type, src, forced } = track;\n\n return {\n id,\n uid,\n kind,\n label,\n language,\n mode,\n type,\n src,\n forced,\n cues: track.cues ? track.cues.map((cue) => fromNativeCue(cue)) : [],\n } as TextTrack;\n}\n\nexport function fromNativeMediaTrackList(tracks: NativeMediaTrackList): MediaTrack[] {\n return tracks.map((track) => fromNativeMediaTrack(track));\n}\n\nexport function fromNativeMediaTrack(track: NativeMediaTrack): MediaTrack {\n const { id, uid, kind, label, language, activeQuality, qualities } = track;\n return {\n kind,\n label,\n language,\n id,\n uid,\n activeQuality,\n qualities,\n } as MediaTrack;\n}\n\nexport function findNativeQualityByUid(mediaTrack: NativeMediaTrack, uid: number | undefined): NativeQuality | undefined {\n return mediaTrack.qualities.find((quality) => quality.uid === uid);\n}\n\nexport function findNativeQualitiesByUid(mediaTrack: NativeMediaTrack | undefined, uid: number | number[] | undefined): NativeQuality[] | undefined {\n if (uid !== undefined && mediaTrack) {\n if (Array.isArray(uid)) {\n return mediaTrack.qualities.filter((quality) => uid.includes(quality.uid));\n } else {\n const quality = findNativeQualityByUid(mediaTrack, uid);\n return quality ? [quality] : undefined;\n }\n }\n return undefined;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["decodeNanInf","fromNativeCue","cue","id","uid","startTime","endTime","content","fromNativeTextTrackList","tracks","map","track","fromNativeTextTrack","kind","label","language","mode","type","src","forced","cues","fromNativeMediaTrackList","fromNativeMediaTrack","activeQuality","qualities","findNativeQualityByUid","mediaTrack","find","quality","findNativeQualitiesByUid","undefined","Array","isArray","filter","includes"],"sources":["TrackUtils.ts"],"sourcesContent":["import type {\n MediaTrack as NativeMediaTrack,\n MediaTrackList as NativeMediaTrackList,\n Quality as NativeQuality,\n TextTrack as NativeTextTrack,\n TextTrackCue as NativeTextTrackCue,\n TextTracksList as NativeTextTrackList,\n} from 'theoplayer';\nimport type { MediaTrack, TextTrack, TextTrackCue } from 'react-native-theoplayer';\nimport { decodeNanInf } from '../../utils/TypeUtils';\n\nexport function fromNativeCue(cue: NativeTextTrackCue): TextTrackCue {\n return {\n id: cue.id,\n uid: cue.uid,\n startTime: decodeNanInf(1e3 * cue.startTime),\n endTime: decodeNanInf(1e3 * cue.endTime),\n content: cue.content,\n } as TextTrackCue;\n}\n\nexport function fromNativeTextTrackList(tracks: NativeTextTrackList): TextTrack[] {\n return tracks.map((track) => fromNativeTextTrack(track));\n}\n\nexport function fromNativeTextTrack(track: NativeTextTrack): TextTrack {\n const { id, uid, kind, label, language, mode, type, src, forced } = track;\n\n return {\n id,\n uid,\n kind,\n label,\n language,\n mode,\n type,\n src,\n forced,\n cues: track.cues ? track.cues.map((cue) => fromNativeCue(cue)) : [],\n } as TextTrack;\n}\n\nexport function fromNativeMediaTrackList(tracks: NativeMediaTrackList): MediaTrack[] {\n return tracks.map((track) => fromNativeMediaTrack(track));\n}\n\nexport function fromNativeMediaTrack(track: NativeMediaTrack): MediaTrack {\n const { id, uid, kind, label, language, activeQuality, qualities } = track;\n return {\n kind,\n label,\n language,\n id,\n uid,\n activeQuality,\n qualities,\n } as MediaTrack;\n}\n\nexport function findNativeQualityByUid(mediaTrack: NativeMediaTrack, uid: number | undefined): NativeQuality | undefined {\n return mediaTrack.qualities.find((quality) => quality.uid === uid);\n}\n\nexport function findNativeQualitiesByUid(mediaTrack: NativeMediaTrack | undefined, uid: number | number[] | undefined): NativeQuality[] | undefined {\n if (uid !== undefined && mediaTrack) {\n if (Array.isArray(uid)) {\n return mediaTrack.qualities.filter((quality) => uid.includes(quality.uid));\n } else {\n const quality = findNativeQualityByUid(mediaTrack, uid);\n return quality ? [quality] : undefined;\n }\n }\n return undefined;\n}\n"],"mappings":"AASA,SAASA,YAAY,QAAQ,uBAAuB;AAEpD,OAAO,SAASC,aAAaA,CAACC,GAAuB,EAAgB;EACnE,OAAO;IACLC,EAAE,EAAED,GAAG,CAACC,EAAE;IACVC,GAAG,EAAEF,GAAG,CAACE,GAAG;IACZC,SAAS,EAAEL,YAAY,CAAC,GAAG,GAAGE,GAAG,CAACG,SAAS,CAAC;IAC5CC,OAAO,EAAEN,YAAY,CAAC,GAAG,GAAGE,GAAG,CAACI,OAAO,CAAC;IACxCC,OAAO,EAAEL,GAAG,CAACK;EACf,CAAC;AACH;AAEA,OAAO,SAASC,uBAAuBA,CAACC,MAA2B,EAAe;EAChF,OAAOA,MAAM,CAACC,GAAG,CAAEC,KAAK,IAAKC,mBAAmB,CAACD,KAAK,CAAC,CAAC;AAC1D;AAEA,OAAO,SAASC,mBAAmBA,CAACD,KAAsB,EAAa;EACrE,MAAM;IAAER,EAAE;IAAEC,GAAG;IAAES,IAAI;IAAEC,KAAK;IAAEC,QAAQ;IAAEC,IAAI;IAAEC,IAAI;IAAEC,GAAG;IAAEC;EAAO,CAAC,GAAGR,KAAK;EAEzE,OAAO;IACLR,EAAE;IACFC,GAAG;IACHS,IAAI;IACJC,KAAK;IACLC,QAAQ;IACRC,IAAI;IACJC,IAAI;IACJC,GAAG;IACHC,MAAM;IACNC,IAAI,EAAET,KAAK,CAACS,IAAI,GAAGT,KAAK,CAACS,IAAI,CAACV,GAAG,CAAER,GAAG,IAAKD,aAAa,CAACC,GAAG,CAAC,CAAC,GAAG;EACnE,CAAC;AACH;AAEA,OAAO,SAASmB,wBAAwBA,CAACZ,MAA4B,EAAgB;EACnF,OAAOA,MAAM,CAACC,GAAG,CAAEC,KAAK,IAAKW,oBAAoB,CAACX,KAAK,CAAC,CAAC;AAC3D;AAEA,OAAO,SAASW,oBAAoBA,CAACX,KAAuB,EAAc;EACxE,MAAM;IAAER,EAAE;IAAEC,GAAG;IAAES,IAAI;IAAEC,KAAK;IAAEC,QAAQ;IAAEQ,aAAa;IAAEC;EAAU,CAAC,GAAGb,KAAK;EAC1E,OAAO;IACLE,IAAI;IACJC,KAAK;IACLC,QAAQ;IACRZ,EAAE;IACFC,GAAG;IACHmB,aAAa;IACbC;EACF,CAAC;AACH;AAEA,OAAO,SAASC,sBAAsBA,CAACC,UAA4B,EAAEtB,GAAuB,EAA6B;EACvH,OAAOsB,UAAU,CAACF,SAAS,CAACG,IAAI,CAAEC,OAAO,IAAKA,OAAO,CAACxB,GAAG,KAAKA,GAAG,CAAC;AACpE;AAEA,OAAO,SAASyB,wBAAwBA,CAACH,UAAwC,EAAEtB,GAAkC,EAA+B;EAClJ,IAAIA,GAAG,KAAK0B,SAAS,IAAIJ,UAAU,EAAE;IACnC,IAAIK,KAAK,CAACC,OAAO,CAAC5B,GAAG,CAAC,EAAE;MACtB,OAAOsB,UAAU,CAACF,SAAS,CAACS,MAAM,CAAEL,OAAO,IAAKxB,GAAG,CAAC8B,QAAQ,CAACN,OAAO,CAACxB,GAAG,CAAC,CAAC;IAC5E,CAAC,MAAM;MACL,MAAMwB,OAAO,GAAGH,sBAAsB,CAACC,UAAU,EAAEtB,GAAG,CAAC;MACvD,OAAOwB,OAAO,GAAG,CAACA,OAAO,CAAC,GAAGE,SAAS;IACxC;EACF;EACA,OAAOA,SAAS;AAClB"}
|
|
@@ -3,7 +3,6 @@ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typ
|
|
|
3
3
|
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
4
4
|
/* eslint-disable @typescript-eslint/no-empty-function */
|
|
5
5
|
|
|
6
|
-
import { PresentationMode } from 'react-native-theoplayer';
|
|
7
6
|
export const defaultWebMediaSessionConfig = {
|
|
8
7
|
skipTime: 15
|
|
9
8
|
};
|
|
@@ -141,42 +140,29 @@ export class WebMediaSession {
|
|
|
141
140
|
isLive() {
|
|
142
141
|
return !isFinite(this._player.duration);
|
|
143
142
|
}
|
|
144
|
-
|
|
143
|
+
isInAd() {
|
|
145
144
|
var _this$_player$ads5;
|
|
146
|
-
return ((_this$_player$ads5 = this._player.ads) === null || _this$_player$ads5 === void 0 ? void 0 : _this$_player$ads5.playing)
|
|
145
|
+
return ((_this$_player$ads5 = this._player.ads) === null || _this$_player$ads5 === void 0 ? void 0 : _this$_player$ads5.playing) === true;
|
|
147
146
|
}
|
|
148
147
|
isInBackground() {
|
|
149
148
|
return document.visibilityState !== 'visible';
|
|
150
149
|
}
|
|
151
|
-
isTrickplayEnabled() {
|
|
152
|
-
// By default, no trickplay for live
|
|
153
|
-
if (this.isLive()) {
|
|
154
|
-
return false;
|
|
155
|
-
}
|
|
156
150
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
if (this.isInBackground()) {
|
|
163
|
-
// Disable trick-play for ads.
|
|
164
|
-
return !(this.isAd() || this.isLive());
|
|
165
|
-
}
|
|
166
|
-
return true;
|
|
151
|
+
// By default, only show trick-play buttons if:
|
|
152
|
+
// - backgroundAudio is enabled, or the player is in foreground;
|
|
153
|
+
// - and, the current asset is neither a live stream, nor an ad.
|
|
154
|
+
isTrickplayEnabled() {
|
|
155
|
+
return (this.isBackgroundAudioEnabled() || !this.isInBackground()) && !this.isLive() && !this.isInAd();
|
|
167
156
|
}
|
|
157
|
+
|
|
158
|
+
// By default, only show a play/pause button if:
|
|
159
|
+
// - backgroundAudio is enabled, or the player is in foreground;
|
|
160
|
+
// - and, the current asset is not an ad.
|
|
168
161
|
isPlayPauseEnabled() {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
}
|
|
174
|
-
// During background playback
|
|
175
|
-
if (this.isInBackground()) {
|
|
176
|
-
// Disable play/pause for ads & live content.
|
|
177
|
-
return !(this.isAd() || this.isLive());
|
|
178
|
-
}
|
|
179
|
-
return true;
|
|
162
|
+
return (this.isBackgroundAudioEnabled() || !this.isInBackground()) && !this.isInAd();
|
|
163
|
+
}
|
|
164
|
+
isBackgroundAudioEnabled() {
|
|
165
|
+
return this._webAdapter.backgroundAudioConfiguration.enabled === true;
|
|
180
166
|
}
|
|
181
167
|
}
|
|
182
168
|
//# sourceMappingURL=WebMediaSession.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["PresentationMode","defaultWebMediaSessionConfig","skipTime","NoOp","mediaSession","_navigator$mediaSessi","_navigator$mediaSessi2","navigator","setActionHandler","setPositionState","window","MediaMetadata","WebMediaSession","constructor","adapter","player","_this$_player$ads","_this$_player$ads2","config","arguments","length","undefined","_defineProperty","updateMetadata","updatePositionState","updateActionHandlers","source","_player","metadata","artwork","poster","displayIconUri","images","filter","image","map","src","title","artist","subtitle","album","duration","playbackRate","currentTime","isLive","isFinite","isNaN","position","_webAdapter","_config","addEventListener","onSourceChange","onLoadedMetadata","onDurationChange","ads","onAdbreakBegin","onAdbreakEnd","isTrickplayEnabled","event","seekOffset","Math","max","min","isPlayPauseEnabled","_this$_player","play","_this$_player2","pause","destroy","_this$_player$ads3","_this$_player$ads4","removeEventListener","isAd","_this$_player$ads5","playing","isInBackground","document","visibilityState","presentationMode","pip"],"sources":["WebMediaSession.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-empty-function */\nimport type { ChromelessPlayer } from 'theoplayer';\nimport type { THEOplayerWebAdapter } from '../THEOplayerWebAdapter';\nimport { PresentationMode } from 'react-native-theoplayer';\n\ninterface WebMediaSessionConfig {\n skipTime: number;\n}\n\nexport const defaultWebMediaSessionConfig: WebMediaSessionConfig = {\n skipTime: 15,\n};\n\nconst NoOp = () => {};\n\n// This prevents unnecessary errors when Media Session API is not available.\nconst mediaSession = (function () {\n const mediaSession = navigator.mediaSession || {};\n mediaSession.setActionHandler = navigator.mediaSession?.setActionHandler || function () {};\n mediaSession.setPositionState = navigator.mediaSession?.setPositionState || function () {};\n window.MediaMetadata = window.MediaMetadata || function () {};\n return mediaSession;\n})();\n\n/**\n * The MediaSession interface of the Media Session API allows a web page to provide custom behaviors for standard media playback interactions, and\n * to report metadata that can be sent by the user agent to the device or operating system for presentation in standardized user interface elements.\n *\n * @link https://w3c.github.io/mediasession\n */\nexport class WebMediaSession {\n private readonly _config: WebMediaSessionConfig;\n private readonly _player: ChromelessPlayer;\n private readonly _webAdapter: THEOplayerWebAdapter;\n\n constructor(adapter: THEOplayerWebAdapter, player: ChromelessPlayer, config: WebMediaSessionConfig = defaultWebMediaSessionConfig) {\n this._player = player;\n this._webAdapter = adapter;\n this._config = config;\n\n this._player.addEventListener('sourcechange', this.onSourceChange);\n this._player.addEventListener('loadedmetadata', this.onLoadedMetadata);\n this._player.addEventListener('durationchange', this.onDurationChange);\n this._player.ads?.addEventListener('adbreakbegin', this.onAdbreakBegin);\n this._player.ads?.addEventListener('adbreakend', this.onAdbreakEnd);\n this.updateActionHandlers();\n }\n\n updateActionHandlers() {\n if (this.isTrickplayEnabled()) {\n mediaSession.setActionHandler('seekbackward', (event) => {\n const skipTime = event.seekOffset || this._config.skipTime;\n this._player.currentTime = Math.max(this._player.currentTime - skipTime, 0);\n });\n mediaSession.setActionHandler('seekforward', (event) => {\n const skipTime = event.seekOffset || this._config.skipTime;\n this._player.currentTime = Math.min(this._player.currentTime + skipTime, this._player.duration);\n });\n } else {\n mediaSession.setActionHandler('seekbackward', NoOp);\n mediaSession.setActionHandler('seekforward', NoOp);\n }\n\n if (this.isPlayPauseEnabled()) {\n mediaSession.setActionHandler('play', () => {\n this._player?.play();\n });\n mediaSession?.setActionHandler('pause', () => {\n this._player?.pause();\n });\n } else {\n mediaSession.setActionHandler('play', NoOp);\n mediaSession.setActionHandler('pause', NoOp);\n }\n }\n\n destroy() {\n this._player.removeEventListener('sourcechange', this.onSourceChange);\n this._player.removeEventListener('loadedmetadata', this.onLoadedMetadata);\n this._player.removeEventListener('durationchange', this.onDurationChange);\n this._player.ads?.removeEventListener('adbreakbegin', this.onAdbreakBegin);\n this._player.ads?.removeEventListener('adbreakend', this.onAdbreakEnd);\n mediaSession.setActionHandler('play', NoOp);\n mediaSession.setActionHandler('pause', NoOp);\n mediaSession.setActionHandler('seekbackward', NoOp);\n mediaSession.setActionHandler('seekforward', NoOp);\n }\n\n private onSourceChange = () => {\n this.updateMetadata();\n this.updatePositionState();\n this.updateActionHandlers();\n };\n\n private onLoadedMetadata = () => {\n this.updateActionHandlers();\n };\n\n private onDurationChange = () => {\n this.updateActionHandlers();\n };\n\n private updateMetadata = () => {\n const source = this._player.source;\n const metadata = source?.metadata;\n const artwork = [source?.poster, metadata?.displayIconUri, ...(metadata?.images ? metadata?.images : [])]\n .filter((image) => image !== undefined)\n .map((image) => {\n if (typeof image === 'string') {\n return { src: image };\n }\n return image;\n });\n mediaSession.metadata = new MediaMetadata({\n title: metadata?.title,\n artist: metadata?.artist || metadata?.subtitle,\n album: metadata?.album,\n artwork,\n });\n };\n\n private updatePositionState = () => {\n const { duration, playbackRate, currentTime } = this._player;\n const isLive = !isFinite(duration);\n if (!isLive) {\n mediaSession.setPositionState({\n // The duration is used to specify the duration in seconds.\n // It should always be positive and positive infinity can be used to indicate media without a defined end such as live playback.\n // NOTE: passing Infinite causes an exception to be thrown.\n duration: isNaN(duration) || duration < 0 ? 0 : duration,\n\n // The playbackRate is used to specify the playback rate.\n // It can be positive to represent forward playback or negative to represent backwards playback. It should not be zero.\n playbackRate,\n\n // The position is used to specify the last reported playback position in seconds. It should always be positive.\n position: currentTime,\n });\n }\n };\n\n private onAdbreakBegin = () => {\n this.updateActionHandlers();\n };\n\n private onAdbreakEnd = () => {\n this.updateActionHandlers();\n };\n\n private isLive(): boolean {\n return !isFinite(this._player.duration);\n }\n\n private isAd(): boolean {\n return this._player.ads?.playing == true;\n }\n\n private isInBackground(): boolean {\n return document.visibilityState !== 'visible';\n }\n\n private isTrickplayEnabled(): boolean {\n // By default, no trickplay for live\n if (this.isLive()) {\n return false;\n }\n\n // In PiP mode, disable trick-play for ads.\n if (this._webAdapter.presentationMode === PresentationMode.pip) {\n return !this.isAd();\n }\n // During background playback\n if (this.isInBackground()) {\n // Disable trick-play for ads.\n return !(this.isAd() || this.isLive());\n }\n return true;\n }\n\n private isPlayPauseEnabled(): boolean {\n // In PiP mode\n if (this._webAdapter.presentationMode === PresentationMode.pip) {\n // Disable play/pause for ads\n return !this.isAd();\n }\n // During background playback\n if (this.isInBackground()) {\n // Disable play/pause for ads & live content.\n return !(this.isAd() || this.isLive());\n }\n return true;\n }\n}\n"],"mappings":";;;AAAA;;AAGA,SAASA,gBAAgB,QAAQ,yBAAyB;AAM1D,OAAO,MAAMC,4BAAmD,GAAG;EACjEC,QAAQ,EAAE;AACZ,CAAC;AAED,MAAMC,IAAI,GAAGA,CAAA,KAAM,CAAC,CAAC;;AAErB;AACA,MAAMC,YAAY,GAAI,YAAY;EAAA,IAAAC,qBAAA,EAAAC,sBAAA;EAChC,MAAMF,YAAY,GAAGG,SAAS,CAACH,YAAY,IAAI,CAAC,CAAC;EACjDA,YAAY,CAACI,gBAAgB,GAAG,EAAAH,qBAAA,GAAAE,SAAS,CAACH,YAAY,cAAAC,qBAAA,uBAAtBA,qBAAA,CAAwBG,gBAAgB,KAAI,YAAY,CAAC,CAAC;EAC1FJ,YAAY,CAACK,gBAAgB,GAAG,EAAAH,sBAAA,GAAAC,SAAS,CAACH,YAAY,cAAAE,sBAAA,uBAAtBA,sBAAA,CAAwBG,gBAAgB,KAAI,YAAY,CAAC,CAAC;EAC1FC,MAAM,CAACC,aAAa,GAAGD,MAAM,CAACC,aAAa,IAAI,YAAY,CAAC,CAAC;EAC7D,OAAOP,YAAY;AACrB,CAAC,EAAG;;AAEJ;AACA;AACA;AACA;AACA;A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,OAAO,EAAE,IAAI,CAACH,IAAI,EAAE,IAAI,IAAI,CAAC5B,MAAM,EAAE,CAAC;IACxC;IACA,OAAO,IAAI;EACb;AACF"}
|
|
1
|
+
{"version":3,"names":["defaultWebMediaSessionConfig","skipTime","NoOp","mediaSession","_navigator$mediaSessi","_navigator$mediaSessi2","navigator","setActionHandler","setPositionState","window","MediaMetadata","WebMediaSession","constructor","adapter","player","_this$_player$ads","_this$_player$ads2","config","arguments","length","undefined","_defineProperty","updateMetadata","updatePositionState","updateActionHandlers","source","_player","metadata","artwork","poster","displayIconUri","images","filter","image","map","src","title","artist","subtitle","album","duration","playbackRate","currentTime","isLive","isFinite","isNaN","position","_webAdapter","_config","addEventListener","onSourceChange","onLoadedMetadata","onDurationChange","ads","onAdbreakBegin","onAdbreakEnd","isTrickplayEnabled","event","seekOffset","Math","max","min","isPlayPauseEnabled","_this$_player","play","_this$_player2","pause","destroy","_this$_player$ads3","_this$_player$ads4","removeEventListener","isInAd","_this$_player$ads5","playing","isInBackground","document","visibilityState","isBackgroundAudioEnabled","backgroundAudioConfiguration","enabled"],"sources":["WebMediaSession.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-empty-function */\nimport type { ChromelessPlayer } from 'theoplayer';\nimport type { THEOplayerWebAdapter } from '../THEOplayerWebAdapter';\n\ninterface WebMediaSessionConfig {\n skipTime: number;\n}\n\nexport const defaultWebMediaSessionConfig: WebMediaSessionConfig = {\n skipTime: 15,\n};\n\nconst NoOp = () => {};\n\n// This prevents unnecessary errors when Media Session API is not available.\nconst mediaSession = (function () {\n const mediaSession = navigator.mediaSession || {};\n mediaSession.setActionHandler = navigator.mediaSession?.setActionHandler || function () {};\n mediaSession.setPositionState = navigator.mediaSession?.setPositionState || function () {};\n window.MediaMetadata = window.MediaMetadata || function () {};\n return mediaSession;\n})();\n\n/**\n * The MediaSession interface of the Media Session API allows a web page to provide custom behaviors for standard media playback interactions, and\n * to report metadata that can be sent by the user agent to the device or operating system for presentation in standardized user interface elements.\n *\n * @link https://w3c.github.io/mediasession\n */\nexport class WebMediaSession {\n private readonly _config: WebMediaSessionConfig;\n private readonly _player: ChromelessPlayer;\n private readonly _webAdapter: THEOplayerWebAdapter;\n\n constructor(adapter: THEOplayerWebAdapter, player: ChromelessPlayer, config: WebMediaSessionConfig = defaultWebMediaSessionConfig) {\n this._player = player;\n this._webAdapter = adapter;\n this._config = config;\n\n this._player.addEventListener('sourcechange', this.onSourceChange);\n this._player.addEventListener('loadedmetadata', this.onLoadedMetadata);\n this._player.addEventListener('durationchange', this.onDurationChange);\n this._player.ads?.addEventListener('adbreakbegin', this.onAdbreakBegin);\n this._player.ads?.addEventListener('adbreakend', this.onAdbreakEnd);\n this.updateActionHandlers();\n }\n\n updateActionHandlers() {\n if (this.isTrickplayEnabled()) {\n mediaSession.setActionHandler('seekbackward', (event) => {\n const skipTime = event.seekOffset || this._config.skipTime;\n this._player.currentTime = Math.max(this._player.currentTime - skipTime, 0);\n });\n mediaSession.setActionHandler('seekforward', (event) => {\n const skipTime = event.seekOffset || this._config.skipTime;\n this._player.currentTime = Math.min(this._player.currentTime + skipTime, this._player.duration);\n });\n } else {\n mediaSession.setActionHandler('seekbackward', NoOp);\n mediaSession.setActionHandler('seekforward', NoOp);\n }\n\n if (this.isPlayPauseEnabled()) {\n mediaSession.setActionHandler('play', () => {\n this._player?.play();\n });\n mediaSession?.setActionHandler('pause', () => {\n this._player?.pause();\n });\n } else {\n mediaSession.setActionHandler('play', NoOp);\n mediaSession.setActionHandler('pause', NoOp);\n }\n }\n\n destroy() {\n this._player.removeEventListener('sourcechange', this.onSourceChange);\n this._player.removeEventListener('loadedmetadata', this.onLoadedMetadata);\n this._player.removeEventListener('durationchange', this.onDurationChange);\n this._player.ads?.removeEventListener('adbreakbegin', this.onAdbreakBegin);\n this._player.ads?.removeEventListener('adbreakend', this.onAdbreakEnd);\n mediaSession.setActionHandler('play', NoOp);\n mediaSession.setActionHandler('pause', NoOp);\n mediaSession.setActionHandler('seekbackward', NoOp);\n mediaSession.setActionHandler('seekforward', NoOp);\n }\n\n private onSourceChange = () => {\n this.updateMetadata();\n this.updatePositionState();\n this.updateActionHandlers();\n };\n\n private onLoadedMetadata = () => {\n this.updateActionHandlers();\n };\n\n private onDurationChange = () => {\n this.updateActionHandlers();\n };\n\n private updateMetadata = () => {\n const source = this._player.source;\n const metadata = source?.metadata;\n const artwork = [source?.poster, metadata?.displayIconUri, ...(metadata?.images ? metadata?.images : [])]\n .filter((image) => image !== undefined)\n .map((image) => {\n if (typeof image === 'string') {\n return { src: image };\n }\n return image;\n });\n mediaSession.metadata = new MediaMetadata({\n title: metadata?.title,\n artist: metadata?.artist || metadata?.subtitle,\n album: metadata?.album,\n artwork,\n });\n };\n\n private updatePositionState = () => {\n const { duration, playbackRate, currentTime } = this._player;\n const isLive = !isFinite(duration);\n if (!isLive) {\n mediaSession.setPositionState({\n // The duration is used to specify the duration in seconds.\n // It should always be positive and positive infinity can be used to indicate media without a defined end such as live playback.\n // NOTE: passing Infinite causes an exception to be thrown.\n duration: isNaN(duration) || duration < 0 ? 0 : duration,\n\n // The playbackRate is used to specify the playback rate.\n // It can be positive to represent forward playback or negative to represent backwards playback. It should not be zero.\n playbackRate,\n\n // The position is used to specify the last reported playback position in seconds. It should always be positive.\n position: currentTime,\n });\n }\n };\n\n private onAdbreakBegin = () => {\n this.updateActionHandlers();\n };\n\n private onAdbreakEnd = () => {\n this.updateActionHandlers();\n };\n\n private isLive(): boolean {\n return !isFinite(this._player.duration);\n }\n\n private isInAd(): boolean {\n return this._player.ads?.playing === true;\n }\n\n private isInBackground(): boolean {\n return document.visibilityState !== 'visible';\n }\n\n // By default, only show trick-play buttons if:\n // - backgroundAudio is enabled, or the player is in foreground;\n // - and, the current asset is neither a live stream, nor an ad.\n private isTrickplayEnabled(): boolean {\n return (this.isBackgroundAudioEnabled() || !this.isInBackground()) && !this.isLive() && !this.isInAd();\n }\n\n // By default, only show a play/pause button if:\n // - backgroundAudio is enabled, or the player is in foreground;\n // - and, the current asset is not an ad.\n private isPlayPauseEnabled(): boolean {\n return (this.isBackgroundAudioEnabled() || !this.isInBackground()) && !this.isInAd();\n }\n\n private isBackgroundAudioEnabled(): boolean {\n return this._webAdapter.backgroundAudioConfiguration.enabled === true;\n }\n}\n"],"mappings":";;;AAAA;;AAQA,OAAO,MAAMA,4BAAmD,GAAG;EACjEC,QAAQ,EAAE;AACZ,CAAC;AAED,MAAMC,IAAI,GAAGA,CAAA,KAAM,CAAC,CAAC;;AAErB;AACA,MAAMC,YAAY,GAAI,YAAY;EAAA,IAAAC,qBAAA,EAAAC,sBAAA;EAChC,MAAMF,YAAY,GAAGG,SAAS,CAACH,YAAY,IAAI,CAAC,CAAC;EACjDA,YAAY,CAACI,gBAAgB,GAAG,EAAAH,qBAAA,GAAAE,SAAS,CAACH,YAAY,cAAAC,qBAAA,uBAAtBA,qBAAA,CAAwBG,gBAAgB,KAAI,YAAY,CAAC,CAAC;EAC1FJ,YAAY,CAACK,gBAAgB,GAAG,EAAAH,sBAAA,GAAAC,SAAS,CAACH,YAAY,cAAAE,sBAAA,uBAAtBA,sBAAA,CAAwBG,gBAAgB,KAAI,YAAY,CAAC,CAAC;EAC1FC,MAAM,CAACC,aAAa,GAAGD,MAAM,CAACC,aAAa,IAAI,YAAY,CAAC,CAAC;EAC7D,OAAOP,YAAY;AACrB,CAAC,EAAG;;AAEJ;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMQ,eAAe,CAAC;EAK3BC,WAAWA,CAACC,OAA6B,EAAEC,MAAwB,EAAgE;IAAA,IAAAC,iBAAA,EAAAC,kBAAA;IAAA,IAA9DC,MAA6B,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAGlB,4BAA4B;IAAAqB,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA,yBAqDxG,MAAM;MAC7B,IAAI,CAACC,cAAc,EAAE;MACrB,IAAI,CAACC,mBAAmB,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EQ+B,MAAMA,CAAA,EAAY;IAAA,IAAAC,kBAAA;IACxB,OAAO,EAAAA,kBAAA,OAAI,CAAC9C,OAAO,CAAC2B,GAAG,cAAAmB,kBAAA,uBAAhBA,kBAAA,CAAkBC,OAAO,MAAK,IAAI;EAC3C;EAEQC,cAAcA,CAAA,EAAY;IAChC,OAAOC,QAAQ,CAACC,eAAe,KAAK,SAAS;EAC/C;;EAEA;EACA;EACA;EACQpB,kBAAkBA,CAAA,EAAY;IACpC,OAAO,CAAC,IAAI,CAACqB,wBAAwB,EAAE,IAAI,CAAC,IAAI,CAACH,cAAc,EAAE,KAAK,CAAC,IAAI,CAAC/B,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC4B,MAAM,EAAE;EACxG;;EAEA;EACA;EACA;EACQT,kBAAkBA,CAAA,EAAY;IACpC,OAAO,CAAC,IAAI,CAACe,wBAAwB,EAAE,IAAI,CAAC,IAAI,CAACH,cAAc,EAAE,KAAK,CAAC,IAAI,CAACH,MAAM,EAAE;EACtF;EAEQM,wBAAwBA,CAAA,EAAY;IAC1C,OAAO,IAAI,CAAC9B,WAAW,CAAC+B,4BAA4B,CAACC,OAAO,KAAK,IAAI;EACvE;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["PresentationMode","DefaultPresentationModeChangeEvent","browserDetection","WebPresentationModeManager","constructor","player","eventForwarder","_defineProperty","inline","undefined","_player","_eventForwarder","presentationMode","_presentationMode","prepareForPresentationModeChanges","IS_SAFARI_","fullscreen","_this$_element","_this$_element$webkit","_element","webkitEnterFullscreen","call","pip","_this$_element2","_this$_element2$webki","webkitSetPresentationMode","_this$_element3","_this$_element3$webki","appElement","document","getElementById","requestFullscreen","_this$_element4","_this$_element4$reque","requestPictureInPicture","exitFullscreen","exitPictureInPicture","elements","element","children","Array","from","tagName","attributes","getNamedItem","onenterpictureinpicture","updatePresentationMode","onleavepictureinpicture","onfullscreenchange","newPresentationMode","fullscreenElement","pictureInPictureElement","previousPresentationMode","dispatchEvent"],"sources":["WebPresentationModeManager.ts"],"sourcesContent":["import type { PlayerEventMap } from 'react-native-theoplayer';\nimport { PresentationMode } from 'react-native-theoplayer';\nimport type * as THEOplayerWeb from 'theoplayer';\nimport { DefaultPresentationModeChangeEvent } from '../event/PlayerEvents';\nimport { browserDetection } from '../../../web/platform/BrowserDetection';\nimport type { DefaultEventDispatcher } from '../event/DefaultEventDispatcher';\n\nexport class WebPresentationModeManager {\n private readonly _player: THEOplayerWeb.ChromelessPlayer;\n private _presentationMode: PresentationMode = PresentationMode.inline;\n private _element: HTMLVideoElement | undefined = undefined;\n private _eventForwarder: DefaultEventDispatcher<PlayerEventMap>;\n\n constructor(player: THEOplayerWeb.ChromelessPlayer, eventForwarder: DefaultEventDispatcher<PlayerEventMap>) {\n this._player = player;\n this._eventForwarder = eventForwarder;\n }\n\n get presentationMode(): PresentationMode {\n return this._presentationMode;\n }\n\n set presentationMode(presentationMode: PresentationMode) {\n if (presentationMode === this._presentationMode) {\n return;\n }\n\n this.prepareForPresentationModeChanges();\n\n // on iOS Safari requestFullscreen isn't supported (https://caniuse.com/?search=requestFullscreen), where we need to use webkit methods on the video element\n if (/*browserDetection.IS_IOS_ && */ browserDetection.IS_SAFARI_) {\n if (presentationMode === PresentationMode.fullscreen) {\n this._element?.webkitEnterFullscreen?.();\n } else if (presentationMode === PresentationMode.pip) {\n this._element?.webkitSetPresentationMode?.(PresentationMode.pip);\n } else {\n this._element?.webkitSetPresentationMode?.(PresentationMode.inline);\n }\n } else {\n // other web-platformsyarn\n\n if (presentationMode === PresentationMode.fullscreen) {\n const appElement = document.getElementById('app');\n void appElement?.requestFullscreen();\n } else if (presentationMode === PresentationMode.pip) {\n void this._element?.requestPictureInPicture?.();\n } else {\n if (this._presentationMode === PresentationMode.fullscreen) {\n void document.exitFullscreen();\n }\n if (this._presentationMode === PresentationMode.pip) {\n void document.exitPictureInPicture();\n }\n }\n }\n }\n\n private prepareForPresentationModeChanges() {\n const elements = this._player.element.children;\n for (const element of Array.from(elements)) {\n if (element.tagName === 'VIDEO' && element.attributes.getNamedItem('src') !== null) {\n this._element = element as HTMLVideoElement;\n }\n }\n // listen for pip updates on element\n if (this._element
|
|
1
|
+
{"version":3,"names":["PresentationMode","DefaultPresentationModeChangeEvent","browserDetection","WebPresentationModeManager","constructor","player","eventForwarder","_defineProperty","inline","undefined","_player","_eventForwarder","presentationMode","_presentationMode","prepareForPresentationModeChanges","IS_SAFARI_","fullscreen","_this$_element","_this$_element$webkit","_element","webkitEnterFullscreen","call","pip","_this$_element2","_this$_element2$webki","webkitSetPresentationMode","_this$_element3","_this$_element3$webki","appElement","document","getElementById","requestFullscreen","_this$_element4","_this$_element4$reque","requestPictureInPicture","exitFullscreen","exitPictureInPicture","elements","element","children","Array","from","tagName","attributes","getNamedItem","onenterpictureinpicture","updatePresentationMode","onleavepictureinpicture","onfullscreenchange","newPresentationMode","fullscreenElement","pictureInPictureElement","previousPresentationMode","dispatchEvent"],"sources":["WebPresentationModeManager.ts"],"sourcesContent":["import type { PlayerEventMap } from 'react-native-theoplayer';\nimport { PresentationMode } from 'react-native-theoplayer';\nimport type * as THEOplayerWeb from 'theoplayer';\nimport { DefaultPresentationModeChangeEvent } from '../event/PlayerEvents';\nimport { browserDetection } from '../../../web/platform/BrowserDetection';\nimport type { DefaultEventDispatcher } from '../event/DefaultEventDispatcher';\n\nexport class WebPresentationModeManager {\n private readonly _player: THEOplayerWeb.ChromelessPlayer;\n private _presentationMode: PresentationMode = PresentationMode.inline;\n private _element: HTMLVideoElement | undefined = undefined;\n private _eventForwarder: DefaultEventDispatcher<PlayerEventMap>;\n\n constructor(player: THEOplayerWeb.ChromelessPlayer, eventForwarder: DefaultEventDispatcher<PlayerEventMap>) {\n this._player = player;\n this._eventForwarder = eventForwarder;\n }\n\n get presentationMode(): PresentationMode {\n return this._presentationMode;\n }\n\n set presentationMode(presentationMode: PresentationMode) {\n if (presentationMode === this._presentationMode) {\n return;\n }\n\n this.prepareForPresentationModeChanges();\n\n // on iOS Safari requestFullscreen isn't supported (https://caniuse.com/?search=requestFullscreen), where we need to use webkit methods on the video element\n if (/*browserDetection.IS_IOS_ && */ browserDetection.IS_SAFARI_) {\n if (presentationMode === PresentationMode.fullscreen) {\n this._element?.webkitEnterFullscreen?.();\n } else if (presentationMode === PresentationMode.pip) {\n this._element?.webkitSetPresentationMode?.(PresentationMode.pip);\n } else {\n this._element?.webkitSetPresentationMode?.(PresentationMode.inline);\n }\n } else {\n // other web-platformsyarn\n\n if (presentationMode === PresentationMode.fullscreen) {\n const appElement = document.getElementById('app');\n void appElement?.requestFullscreen();\n } else if (presentationMode === PresentationMode.pip) {\n void this._element?.requestPictureInPicture?.();\n } else {\n if (this._presentationMode === PresentationMode.fullscreen) {\n void document.exitFullscreen();\n }\n if (this._presentationMode === PresentationMode.pip) {\n void document.exitPictureInPicture();\n }\n }\n }\n }\n\n private prepareForPresentationModeChanges() {\n const elements = this._player.element.children;\n for (const element of Array.from(elements)) {\n if (element.tagName === 'VIDEO' && element.attributes.getNamedItem('src') !== null) {\n this._element = element as HTMLVideoElement;\n }\n }\n // listen for pip updates on element\n if (this._element !== undefined) {\n this._element.onenterpictureinpicture = () => {\n this.updatePresentationMode();\n };\n this._element.onleavepictureinpicture = () => {\n this.updatePresentationMode();\n };\n }\n // listen for fullscreen updates on document\n document.onfullscreenchange = () => {\n this.updatePresentationMode();\n };\n }\n\n private updatePresentationMode() {\n // detect new presentation mode\n let newPresentationMode: PresentationMode = PresentationMode.inline;\n if (document.fullscreenElement !== null) {\n newPresentationMode = PresentationMode.fullscreen;\n } else if (document.pictureInPictureElement !== null) {\n newPresentationMode = PresentationMode.pip;\n }\n\n // when changed, notify by dispatching presentationModeChange event\n const previousPresentationMode = this._presentationMode;\n if (newPresentationMode !== previousPresentationMode) {\n this._presentationMode = newPresentationMode;\n this._eventForwarder.dispatchEvent(new DefaultPresentationModeChangeEvent(this._presentationMode, previousPresentationMode));\n }\n }\n}\n"],"mappings":";;;AAC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K,CAAC,KAAK,IAAI,EAAE;QAClF,IAAI,CAACzB,QAAQ,GAAGmB,OAA2B;MAC7C;IACF;IACA;IACA,IAAI,IAAI,CAACnB,QAAQ,KAAKV,SAAS,EAAE;MAC/B,IAAI,CAACU,QAAQ,CAAC0B,uBAAuB,GAAG,MAAM;QAC5C,IAAI,CAACC,sBAAsB,EAAE;MAC/B,CAAC;MACD,IAAI,CAAC3B,QAAQ,CAAC4B,uBAAuB,GAAG,MAAM;QAC5C,IAAI,CAACD,sBAAsB,EAAE;MAC/B,CAAC;IACH;IACA;IACAjB,QAAQ,CAACmB,kBAAkB,GAAG,MAAM;MAClC,IAAI,CAACF,sBAAsB,EAAE;IAC/B,CAAC;EACH;EAEQA,sBAAsBA,CAAA,EAAG;IAC/B;IACA,IAAIG,mBAAqC,GAAGjD,gBAAgB,CAACQ,MAAM;IACnE,IAAIqB,QAAQ,CAACqB,iBAAiB,KAAK,IAAI,EAAE;MACvCD,mBAAmB,GAAGjD,gBAAgB,CAACgB,UAAU;IACnD,CAAC,MAAM,IAAIa,QAAQ,CAACsB,uBAAuB,KAAK,IAAI,EAAE;MACpDF,mBAAmB,GAAGjD,gBAAgB,CAACsB,GAAG;IAC5C;;IAEA;IACA,MAAM8B,wBAAwB,GAAG,IAAI,CAACvC,iBAAiB;IACvD,IAAIoC,mBAAmB,KAAKG,wBAAwB,EAAE;MACpD,IAAI,CAACvC,iBAAiB,GAAGoC,mBAAmB;MAC5C,IAAI,CAACtC,eAAe,CAAC0C,aAAa,CAAC,IAAIpD,kCAAkC,CAAC,IAAI,CAACY,iBAAiB,EAAEuC,wBAAwB,CAAC,CAAC;IAC9H;EACF;AACF"}
|
|
@@ -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
|
}
|