rx-player 4.3.1-dev.2025041000 → 4.3.1-dev.2025041002
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 +1 -3
- package/VERSION +1 -1
- package/dist/commonjs/main_thread/api/public_api.js +2 -2
- package/dist/es2017/main_thread/api/public_api.js +2 -2
- package/dist/rx-player.js +2 -2
- package/dist/rx-player.min.js +1 -1
- package/package.json +1 -1
- package/src/main_thread/api/public_api.ts +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
## Current dev build: v4.3.1-dev.
|
|
4
|
-
|
|
3
|
+
## Current dev build: v4.3.1-dev.2025041002
|
|
5
4
|
|
|
6
5
|
- fix(DRM): renew the mediaKeySystemAccess on Edge and Firefox when using a Playready keySystem. [#1694]
|
|
7
6
|
- [MULTI_THREAD] Communicate to `/init` whether we're relying on MSE-in-worker [#1669]
|
|
8
7
|
|
|
9
|
-
|
|
10
8
|
### Bug fixes
|
|
11
9
|
|
|
12
10
|
- Firefox: check extensively Playready DRMs support before using them to work-around
|
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
4.3.1-dev.
|
|
1
|
+
4.3.1-dev.2025041002
|
|
@@ -162,7 +162,7 @@ var Player = /** @class */ (function (_super) {
|
|
|
162
162
|
// Workaround to support Firefox autoplay on FF 42.
|
|
163
163
|
// See: https://bugzilla.mozilla.org/show_bug.cgi?id=1194624
|
|
164
164
|
videoElement.preload = "auto";
|
|
165
|
-
_this.version = /* PLAYER_VERSION */ "4.3.1-dev.
|
|
165
|
+
_this.version = /* PLAYER_VERSION */ "4.3.1-dev.2025041002";
|
|
166
166
|
_this.log = log_1.default;
|
|
167
167
|
_this.state = "STOPPED";
|
|
168
168
|
_this.videoElement = videoElement;
|
|
@@ -2771,5 +2771,5 @@ var Player = /** @class */ (function (_super) {
|
|
|
2771
2771
|
Player._priv_currentlyUsedVideoElements = new WeakSet();
|
|
2772
2772
|
return Player;
|
|
2773
2773
|
}(event_emitter_1.default));
|
|
2774
|
-
Player.version = /* PLAYER_VERSION */ "4.3.1-dev.
|
|
2774
|
+
Player.version = /* PLAYER_VERSION */ "4.3.1-dev.2025041002";
|
|
2775
2775
|
exports.default = Player;
|
|
@@ -144,7 +144,7 @@ class Player extends EventEmitter {
|
|
|
144
144
|
// Workaround to support Firefox autoplay on FF 42.
|
|
145
145
|
// See: https://bugzilla.mozilla.org/show_bug.cgi?id=1194624
|
|
146
146
|
videoElement.preload = "auto";
|
|
147
|
-
this.version = /* PLAYER_VERSION */ "4.3.1-dev.
|
|
147
|
+
this.version = /* PLAYER_VERSION */ "4.3.1-dev.2025041002";
|
|
148
148
|
this.log = log;
|
|
149
149
|
this.state = "STOPPED";
|
|
150
150
|
this.videoElement = videoElement;
|
|
@@ -2549,5 +2549,5 @@ class Player extends EventEmitter {
|
|
|
2549
2549
|
* Use of a WeakSet ensure the object is garbage collected if it's not used anymore.
|
|
2550
2550
|
*/
|
|
2551
2551
|
Player._priv_currentlyUsedVideoElements = new WeakSet();
|
|
2552
|
-
Player.version = /* PLAYER_VERSION */ "4.3.1-dev.
|
|
2552
|
+
Player.version = /* PLAYER_VERSION */ "4.3.1-dev.2025041002";
|
|
2553
2553
|
export default Player;
|
package/dist/rx-player.js
CHANGED
|
@@ -38135,7 +38135,7 @@ ${event}`
|
|
|
38135
38135
|
} = parseConstructorOptions(options);
|
|
38136
38136
|
videoElement.preload = "auto";
|
|
38137
38137
|
this.version = /* PLAYER_VERSION */
|
|
38138
|
-
"4.3.1-dev.
|
|
38138
|
+
"4.3.1-dev.2025041002";
|
|
38139
38139
|
this.log = log_default;
|
|
38140
38140
|
this.state = "STOPPED";
|
|
38141
38141
|
this.videoElement = videoElement;
|
|
@@ -40760,7 +40760,7 @@ ${event}`
|
|
|
40760
40760
|
_Player._priv_currentlyUsedVideoElements = /* @__PURE__ */ new WeakSet();
|
|
40761
40761
|
var Player = _Player;
|
|
40762
40762
|
Player.version = /* PLAYER_VERSION */
|
|
40763
|
-
"4.3.1-dev.
|
|
40763
|
+
"4.3.1-dev.2025041002";
|
|
40764
40764
|
var public_api_default = Player;
|
|
40765
40765
|
|
|
40766
40766
|
// src/main_thread/api/index.ts
|
package/dist/rx-player.min.js
CHANGED
|
@@ -15,4 +15,4 @@ Trying to unlock by seeking to the next Period`),this._playbackObserver.setCurre
|
|
|
15
15
|
`+Bb(t.buffered,t.position.getPolled()),`
|
|
16
16
|
${e}`),this._observationRef.setValue(t)}};function pp(n,e){if(n===null)return 0;let t=e?"LOW_LATENCY":"DEFAULT",{RESUME_GAP_AFTER_SEEKING:r,RESUME_GAP_AFTER_NOT_ENOUGH_DATA:i,RESUME_GAP_AFTER_BUFFERING:o}=L.getCurrent();switch(n.reason){case"seeking":return r[t];case"not-ready":return i[t];case"buffering":return o[t]}}function Lb(n,e,t,r,i){let{REBUFFERING_GAP:o}=L.getCurrent(),a=i?"LOW_LATENCY":"DEFAULT";return e===void 0?t&&Math.abs(r-n)<=o[a]:e!==null&&r-e.end<=o[a]}function gp(n){let{buffered:e,currentTime:t,duration:r,ended:i,paused:o,playbackRate:a,readyState:s,seeking:d}=n;return{buffered:e,position:t,duration:r,ended:i,paused:o,playbackRate:a,readyState:s,seeking:d}}function Nb({previousObservation:n,currentObservation:e,basePosition:t,observationEvent:r,withMediaSource:i,lowLatencyMode:o,bufferGap:a,fullyLoaded:s}){let{REBUFFERING_GAP:d}=L.getCurrent(),{position:u,paused:c,readyState:l,ended:f}=e,{rebuffering:p,event:g,position:b}=n,h=l>=1&&r!=="loadedmetadata"&&p===null&&!(s||f),I=null,T,R,E=o?d.LOW_LATENCY:d.DEFAULT;if(i){if(h)a===1/0?(T=!0,I=t):a===void 0?l<3&&(T=!0,I=void 0):a<=E&&(T=!0,I=t+a);else if(p!==null){let v=pp(p,o);T!==!0&&p!==null&&l>1&&(s||f||a!==void 0&&isFinite(a)&&a>v)||a===void 0&&l>=3?R=!0:a===void 0?I=void 0:a===1/0?I=t:a<=v&&(I=t+a)}}else h&&(!c&&r==="timeupdate"&&g==="timeupdate"&&u===b.getPolled()||r==="seeking"&&(a===1/0||a===void 0&&l<3))?T=!0:p!==null&&(r!=="seeking"&&u!==b.getPolled()||r==="canplay"||a===void 0&&l>=3||a!==void 0&&a<1/0&&(a>pp(p,o)||s||f))&&(R=!0);if(R===!0)return null;if(T===!0||p!==null){let v;return r==="seeking"||p!==null&&p.reason==="seeking"||e.seeking?v="seeking":l===1?v="not-ready":v="buffering",p!==null&&p.reason===v?{reason:p.reason,timestamp:p.timestamp,position:I}:{reason:v,timestamp:V(),position:I}}return null}function Ub(n,e,t,r){let{MINIMUM_BUFFER_AMOUNT_BEFORE_FREEZING:i}=L.getCurrent();return n.freezing!==null?e.ended||e.paused||e.readyState===0||e.playbackRate===0||n.position.getPolled()!==e.position?null:n.freezing:t==="timeupdate"&&r!==void 0&&r>i&&!e.ended&&!e.paused&&e.readyState>=1&&e.playbackRate!==0&&e.position===n.position.getPolled()?{timestamp:V()}:null}function Bb(n,e){let t="",r="";for(let i=0;i<n.length;i++){let o=n.start(i),a=n.end(i),s=o.toFixed(2),d=a.toFixed(2),u=(a-o).toFixed(2),c=`${s}|==${u}==|${d}`;if(t+=c,r.length===0&&a>e){let l=t.length-Math.floor(c.length/2);r=" ".repeat(l)+`^${e}`}if(i<n.length-1){let l=n.start(i+1),p=` ~${(l-a).toFixed(2)}~ `;if(t+=p,r.length===0&&e<l){let g=t.length-Math.floor(p.length/2);r=" ".repeat(g)+`^${e}`}}}return r.length===0&&(r=" ".repeat(t.length)+`^${e}`),t+`
|
|
17
17
|
`+r}function Fb(n){let e=gp(n);return Y(e,{rebuffering:null,event:"init",seeking:0,position:new nr(e.position,null),freezing:null,bufferGap:0,currentRange:null,fullyLoaded:!1})}async function Kl(n,e){let{time:t,container:r}=e;if(n===null||n.fetchThumbnailDataCallback===null||n.manifest===null)return Promise.reject(new ct("NO_CONTENT","Cannot get thumbnail: no content loaded"));let{thumbnailRequestsInfo:i,currentContentCanceller:o}=n,a=new U;a.linkToSignal(o.signal);let s,d=i.pendingRequests.get(r);d==null||d.cancel(),i.pendingRequests.set(r,a);let u=()=>{a.cancel(),i.pendingRequests.delete(r),setTimeout(()=>{s!==void 0&&URL.revokeObjectURL(s)},0)};try{let l=Vn(n.manifest,t);if(l===void 0)throw new ct("NO_THUMBNAIL","Wanted Period not found.");let f=l.thumbnailTracks,p=e.thumbnailTrackId!==void 0?Q(f,v=>v.id===e.thumbnailTrackId):f[0];if(p===void 0)throw e.thumbnailTrackId!==void 0?new ct("NO_THUMBNAIL","Given `thumbnailTrackId` not found"):new ct("NO_THUMBNAIL","Wanted Period has no thumbnail track.");let{lastResponse:g}=i,b;if(g!==null&&g.thumbnailTrackId===p.id&&g.periodId===l.id){let v=g.response.thumbnails;v.length>0&&t>=v[0].start&&t<v[v.length-1].end&&(b=g.response)}if(b===void 0&&(b=await n.fetchThumbnailDataCallback(l.id,p.id,t),i.lastResponse={response:b,periodId:l.id,thumbnailTrackId:p.id}),a.signal.cancellationError!==null)throw a.signal.cancellationError;let h=document.createElement("canvas"),I=h.getContext("2d");if(I===null)throw new ct("RENDERING","Cannot display thumbnail: cannot create canvas context");let T=pe(b.thumbnails,v=>v.start<=t&&v.end>t);if(T<0)throw new Error("Cannot display thumbnail: time not found in fetched data");let R=new Image,E=new Blob([b.data],{type:b.mimeType});return s=URL.createObjectURL(E),R.src=s,h.height=b.thumbnails[T].height,h.width=b.thumbnails[T].width,new Promise((v,k)=>{R.onload=()=>{try{I.drawImage(R,b.thumbnails[T].offsetX,b.thumbnails[T].offsetY,b.thumbnails[T].width,b.thumbnails[T].height,0,0,b.thumbnails[T].width,b.thumbnails[T].height),h.style.width="100%",h.style.height="100%",h.className="__rx-thumbnail__",c(),r.appendChild(h),v()}catch(x){k(new ct("RENDERING","Could not draw the image in a canvas:"+(x instanceof Error?x.toString():"Unknown Error")))}u()},R.onerror=()=>{e.keepPreviousThumbnailOnError!==!0&&c(),k(new ct("RENDERING","Could not load the corresponding image in the DOM")),u()}})}catch(l){if(e.keepPreviousThumbnailOnError!==!0&&c(),l!==null&&l===a.signal.cancellationError)throw new ct("ABORTED","Thumbnail rendering has been aborted");let f=Ee(l,{defaultCode:"NONE",defaultReason:"Unknown error"}),p;throw f.type==="NETWORK_ERROR"?p=new ct("LOADING",f.message):p=new ct("NOT_FOUND",f.message),u(),p}function c(){for(let l=r.children.length-1;l>=0;l--){let f=r.children[l];f.className==="__rx-thumbnail__"&&r.removeChild(f)}}}var ct=class n extends Error{constructor(e,t){super(Je(e,t)),Object.setPrototypeOf(this,n.prototype),this.name="ThumbnailRenderingError",this.code=e}};var go=class extends ae{constructor(e){super(),this._canceller=new U,this._adaptationRef=e,this._updateToken=!1,this._lastEmitted=void 0,this.refresh=Z}hasSetTrack(){return this._adaptationRef.getValue()!==void 0}updateTrack(e){if(this._updateToken=!0,e===null){if(this._lastEmitted===null)return;this._updateToken=!1,this._canceller.cancel(),this._canceller=new U,this._lastEmitted=null,this._adaptationRef.setValue(null);return}let{adaptation:t,switchingMode:r,relativeResumingPosition:i}=e;this._canceller.cancel(),this._canceller=new U;let o=this._constructLockedRepresentationsReference(e);this._updateToken&&(this._lastEmitted={adaptation:t,switchingMode:r,lockedRepresentations:null},this._updateToken=!1,this._adaptationRef.setValue({adaptationId:t.id,switchingMode:r,representations:o,relativeResumingPosition:i}))}_constructLockedRepresentationsReference(e){let t=new G({representationIds:[],switchingMode:"lazy"}),r=this;return this.refresh=i,this._canceller.signal.register(o),e.lockedRepresentations.onUpdate(i,{clearSignal:this._canceller.signal,emitCurrentValue:!1}),i(),t;function i(){let a=e.lockedRepresentations.getValue(),s,d;if(a===null)d=e.adaptation.representations.filter(l=>Tt(l)===!0),s="lazy";else{let{representationIds:l}=a;if(s=a.switchingMode,d=e.adaptation.representations.filter(p=>X(l,p.id)).filter(p=>Tt(p)===!0),d.length===0){r.trigger("noPlayableLockedRepresentation",null);return}}if(d.length<=0){r.trigger("noPlayableRepresentation",null);return}let u=t.getValue(),c=d.map(l=>l.id).slice().sort();if(c.length!==u.representationIds.length){t.setValue({representationIds:c,switchingMode:s});return}for(let l=0;l<c.length;l++)if(u.representationIds[l]!==c[l]){t.setValue({representationIds:c,switchingMode:s});return}}function o(){r.refresh=Z}}dispose(){this.removeEventListener(),this._canceller.cancel(),this._adaptationRef.finish()}};var ho=class extends ae{constructor(e){var t;super(),this._storedPeriodInfo=[],this._isDisposed=!1,this._cachedPeriodInfo=new WeakMap,this._isTrickModeTrackEnabled=e.preferTrickModeTracks,this._defaultAudioTrackSwitchingMode=(t=e.defaultAudioTrackSwitchingMode)!=null?t:L.getCurrent().DEFAULT_AUDIO_TRACK_SWITCHING_MODE}getAvailablePeriods(){return this._storedPeriodInfo.reduce((e,t)=>(t.isPeriodAdvertised&&e.push(Kt(t.period)),e),[])}onManifestCodecSupportUpdate(){this._selectInitialTrackIfNeeded()}onManifestUpdate(e){var a,s,d,u,c,l;let{DEFAULT_VIDEO_TRACK_SWITCHING_MODE:t}=L.getCurrent(),{periods:r}=e;if(y.CURRENT_ENV===y.DEV)for(let f=1;f<r.length;f++)ee(r[f-1].start<=r[f].start);let i=[],o=0;for(let f=0;f<this._storedPeriodInfo.length;f++){let p=this._storedPeriodInfo[f].period,g=r[o];if(g===void 0)for(let b=this._storedPeriodInfo.length-1;b>=f;b--)this._storedPeriodInfo[b].inManifest=!1,Vl(this._storedPeriodInfo[b])&&this._removePeriodObject(b);else if(p===g){o++;let b=this._storedPeriodInfo[f].text.storedSettings;if(!_(b)&&!gt(g,"text").some(E=>E.id===b.adaptation.id)){m.warn("TS: Chosen text Adaptation not available anymore");let E=this._storedPeriodInfo[f];if(E.text.storedSettings=null,this.trigger("trackUpdate",{period:Kt(g),trackType:"text",reason:"missing"}),this._isDisposed)return;let v=ft(this._storedPeriodInfo,E.period.id);v!==void 0&&v.isPeriodAdvertised&&v.text.storedSettings===null&&((a=v.text.dispatcher)==null||a.updateTrack(null))}let h=this._storedPeriodInfo[f].video.storedSettings;if(!_(h)){let T=gt(g,"video");if(!T.some(E=>E.id===h.adaptation.id)){m.warn("TS: Chosen video Adaptation not available anymore");let E=this._storedPeriodInfo[f],v;if(T.length===0)v=null;else{let x=T[0],P=Va(x,this._isTrickModeTrackEnabled),M=new G(null);v={adaptationBase:x,adaptation:P,switchingMode:t,lockedRepresentations:M}}if(E.video.storedSettings=v,this.trigger("trackUpdate",{period:Kt(g),trackType:"video",reason:"missing"}),this._isDisposed)return;let k=ft(this._storedPeriodInfo,E.period.id);k!==void 0&&k.isPeriodAdvertised&&k.video.storedSettings===v&&((s=k.video.dispatcher)==null||s.updateTrack(v))}}let I=this._storedPeriodInfo[f].audio.storedSettings;if(!_(I)){let T=gt(g,"audio");if(!T.some(E=>E.id===I.adaptation.id)){m.warn("TS: Chosen audio Adaptation not available anymore");let E=this._storedPeriodInfo[f],v=T.length===0?null:{adaptation:T[0],switchingMode:this._defaultAudioTrackSwitchingMode,lockedRepresentations:new G(null)};if(E.audio.storedSettings=v,this.trigger("trackUpdate",{period:Kt(g),trackType:"audio",reason:"missing"}),this._isDisposed)return;let k=ft(this._storedPeriodInfo,E.period.id);k!==void 0&&k.isPeriodAdvertised&&k.audio.storedSettings===v&&((d=k.audio.dispatcher)==null||d.updateTrack(v))}}}else if(p.start<=g.start)this._storedPeriodInfo[f].inManifest=!1,Vl(this._storedPeriodInfo[f])&&(this._removePeriodObject(f),f--);else{let b=zl(g,!0);this._storedPeriodInfo.splice(f,0,b),i.push(b),o++}}if(o<r.length){let f=r.slice(o).map(p=>zl(p,!0));this._storedPeriodInfo.push(...f),i.push(...f)}for(let f of this._storedPeriodInfo)(u=f.audio.dispatcher)==null||u.refresh(),(c=f.video.dispatcher)==null||c.refresh(),(l=f.text.dispatcher)==null||l.refresh()}onDecipherabilityUpdates(){var e,t,r;for(let i of this._storedPeriodInfo)(e=i.audio.dispatcher)==null||e.refresh(),(t=i.video.dispatcher)==null||t.refresh(),(r=i.text.dispatcher)==null||r.refresh()}addTrackReference(e,t,r){m.debug("TS: Adding Track Reference",e,t.id);let i=ft(this._storedPeriodInfo,t.id);if(i===void 0){i=zl(t,!1);let s=!1;for(let d=0;d<this._storedPeriodInfo.length;d++)this._storedPeriodInfo[d].period.start>t.start&&(this._storedPeriodInfo.splice(d,0,i),s=!0);s||this._storedPeriodInfo.push(i)}i[e].dispatcher!==null&&(m.error(`TS: Subject already added for ${e} and Period ${t.start}`),i[e].dispatcher.dispose());let o=new go(r);if(i[e].dispatcher=o,o.addEventListener("noPlayableRepresentation",()=>{var l,f,p,g;let s=Q((l=t.adaptations[e])!=null?l:[],b=>b.supportStatus.hasSupportedCodec===!1||b.supportStatus.isDecipherable===!1?!1:b.representations.filter(I=>Tt(I)===!0).length>0);if(s===void 0){let b=new te("NO_PLAYABLE_REPRESENTATION",`No ${e} Representation can be played`,{tracks:void 0});this.trigger("error",b),this.dispose();return}let d=(f=ft(this._storedPeriodInfo,t.id))==null?void 0:f[e];if(_(d))return;let u=e==="audio"?this._defaultAudioTrackSwitchingMode:"reload",c={adaptation:s,switchingMode:u,lockedRepresentations:new G(null)};d.storedSettings=c,this.trigger("trackUpdate",{period:Kt(t),trackType:e,reason:"no-playable-representation"}),!this._isDisposed&&(d=(p=ft(this._storedPeriodInfo,t.id))==null?void 0:p[e],!(_(d)||d.storedSettings!==c)&&((g=d.dispatcher)==null||g.updateTrack(c)))}),o.addEventListener("noPlayableLockedRepresentation",()=>{i!==void 0&&(this.unlockVideoRepresentations(i),this.trigger("brokenRepresentationsLock",{period:{id:t.id,start:t.start,end:t.end},trackType:e}))}),this._selectInitialTrackIfNeeded(),this._shouldAdvertisePeriod(i)&&(i.isPeriodAdvertised=!0,this.trigger("newAvailablePeriods",[{id:t.id,start:t.start,end:t.end}]),this._isDisposed))return;let a=["audio","video","text"];for(let s of a){let d=i[s];if(i.isPeriodAdvertised&&d.dispatcher!==null&&!d.dispatcher.hasSetTrack()&&d.storedSettings!==void 0&&d.dispatcher.updateTrack(d.storedSettings),this._isDisposed)return}}removeTrackReference(e,t){m.debug("TS: Removing Track Reference",e,t);let r;for(let a=0;a<this._storedPeriodInfo.length;a++)if(this._storedPeriodInfo[a].period.id===t){r=a;break}if(r===void 0){m.warn(`TS: ${e} not found for period`,t);return}let i=this._storedPeriodInfo[r],o=i[e];if((o==null?void 0:o.dispatcher)===null){m.warn(`TS: TrackDispatcher already removed for ${e} and Period ${t}`);return}o.dispatcher.dispose(),o.dispatcher=null,Vl(i)&&this._removePeriodObject(r)}getPeriodObjectFromPeriod(e){let t=ft(this._storedPeriodInfo,e.id);return t===void 0&&e!==void 0?this._cachedPeriodInfo.get(e):t}getPeriodObjectFromId(e){return ft(this._storedPeriodInfo,e)}disableVideoTrickModeTracks(){this._isTrickModeTrackEnabled&&(this._isTrickModeTrackEnabled=!1,this._resetVideoTrackChoices("trickmode-disabled"))}enableVideoTrickModeTracks(){this._isTrickModeTrackEnabled||(this._isTrickModeTrackEnabled=!0,this._resetVideoTrackChoices("trickmode-enabled"))}resetPeriodObjects(){var e,t,r;m.debug("TS: Resetting Period Objects");for(let i=this._storedPeriodInfo.length-1;i>=0;i--){let o=this._storedPeriodInfo[i];(e=o.audio.dispatcher)==null||e.dispose(),o.audio.dispatcher=null,(t=o.video.dispatcher)==null||t.dispose(),o.video.dispatcher=null,(r=o.text.dispatcher)==null||r.dispose(),o.text.dispatcher=null,o.inManifest||this._removePeriodObject(i)}}isTrickModeEnabled(){return this._isTrickModeTrackEnabled}setAudioTrack(e){let{periodRef:t,trackId:r,switchingMode:i,lockedRepresentations:o,relativeResumingPosition:a}=e;return this._setAudioOrTextTrack({bufferType:"audio",periodRef:t,trackId:r,switchingMode:i!=null?i:this._defaultAudioTrackSwitchingMode,lockedRepresentations:o,relativeResumingPosition:a})}setTextTrack(e,t){return this._setAudioOrTextTrack({bufferType:"text",periodRef:e,trackId:t,switchingMode:"direct",lockedRepresentations:null,relativeResumingPosition:void 0})}_setAudioOrTextTrack({bufferType:e,periodRef:t,trackId:r,switchingMode:i,lockedRepresentations:o,relativeResumingPosition:a}){var p,g;if(!t.isPeriodAdvertised)throw new Error("Wanted Period not yet advertised.");let s=t.period,d=Q((p=s.adaptations[e])!=null?p:[],({id:b,supportStatus:h})=>h.hasSupportedCodec!==!1&&h.isDecipherable!==!1&&b===r);if(d===void 0)throw new Error(`Wanted ${e} track not found.`);let u=t[e],c;if(o===null)c=new G(null);else{let b=this._getRepresentationsToLock(d,o),h=e==="audio"?this._defaultAudioTrackSwitchingMode:"direct";c=new G({representationIds:b,switchingMode:h})}let l={adaptation:d,switchingMode:i,lockedRepresentations:c,relativeResumingPosition:a};if(u.storedSettings=l,this.trigger("trackUpdate",{period:Kt(s),trackType:e,reason:"manual"}),this._isDisposed)return;let f=ft(this._storedPeriodInfo,s.id);f!==void 0&&f[e].storedSettings===l&&((g=f[e].dispatcher)==null||g.updateTrack(l))}setVideoTrack(e){var b,h;let{periodRef:t,trackId:r,switchingMode:i,lockedRepresentations:o,relativeResumingPosition:a}=e;if(!t.isPeriodAdvertised)throw new Error("Wanted Period not yet advertised.");let s=t.period,d=Q((b=s.adaptations.video)!=null?b:[],({id:I,supportStatus:T})=>T.isDecipherable!==!1&&T.hasSupportedCodec!==!1&&I===r);if(d===void 0)throw new Error("Wanted video track not found.");let{DEFAULT_VIDEO_TRACK_SWITCHING_MODE:u}=L.getCurrent(),c=t.video,l=Va(d,this._isTrickModeTrackEnabled),f;if(o===null)f=new G(null);else{let I=this._getRepresentationsToLock(d,o),T=u;f=new G({representationIds:I,switchingMode:T})}let p={adaptationBase:d,switchingMode:i!=null?i:u,adaptation:l,relativeResumingPosition:a,lockedRepresentations:f};if(c.storedSettings=p,this.trigger("trackUpdate",{period:Kt(s),trackType:"video",reason:"manual"}),this._isDisposed)return;let g=ft(this._storedPeriodInfo,s.id);g!==void 0&&g.video.storedSettings===p&&((h=g.video.dispatcher)==null||h.updateTrack(p))}disableTrack(e,t){var o,a;if(!e.isPeriodAdvertised)throw new Error("Wanted Period not yet advertised.");let r=e[t];if(r.storedSettings===null||(t!=="text"&&((o=e[t].storedSettings)==null||o.lockedRepresentations.finish()),r.storedSettings=null,this.trigger("trackUpdate",{period:Kt(e.period),trackType:t,reason:"manual"}),this._isDisposed))return;let i=ft(this._storedPeriodInfo,e.period.id);i!==void 0&&i[t].storedSettings===null&&((a=i[t].dispatcher)==null||a.updateTrack(null))}getChosenAudioTrack(e,t){return _(e.audio.storedSettings)?null:Mo(e.audio.storedSettings.adaptation,t)}getChosenTextTrack(e){return _(e.text.storedSettings)?null:Ao(e.text.storedSettings.adaptation)}getChosenVideoTrack(e,t){return _(e.video.storedSettings)?null:xo(e.video.storedSettings.adaptation,t)}getAvailableAudioTracks(e,t){let r=e.audio.storedSettings,i=_(r)?null:r.adaptation.id;return gt(e.period,"audio").map(a=>{let s=i===null?!1:i===a.id;return Y(Mo(a,t),{active:s})})}getAvailableTextTracks(e){let t=e.text.storedSettings,r=_(t)?null:t.adaptation.id;return gt(e.period,"text").map(o=>{let a=r===null?!1:r===o.id;return Y(Ao(o),{active:a})})}getAvailableVideoTracks(e,t){let r=e.video.storedSettings,i=_(r)?void 0:r.adaptation.id;return gt(e.period,"video").map(a=>{let s=i===null?!1:i===a.id,d=xo(a,t),u=d.trickModeTracks!==void 0?d.trickModeTracks.map(l=>{let f=i===null?!1:i===l.id;return Y(l,{active:f})}):[],c=Y(d,{active:s});return u!==void 0&&(c.trickModeTracks=u),c})}getLockedAudioRepresentations(e){let{storedSettings:t}=e.audio;if(_(t))return null;let r=t.lockedRepresentations.getValue();return r===null?null:r.representationIds}getLockedVideoRepresentations(e){let{storedSettings:t}=e.video;if(_(t))return null;let r=t.lockedRepresentations.getValue();return r===null?null:r.representationIds}lockAudioRepresentations(e,t){var s;let{storedSettings:r}=e.audio;if(_(r))return;let{DEFAULT_AUDIO_REPRESENTATIONS_SWITCHING_MODE:i}=L.getCurrent(),o=this._getRepresentationsToLock(r.adaptation,t.representations),a=(s=t.switchingMode)!=null?s:i;r.lockedRepresentations.setValue({representationIds:o,switchingMode:a})}lockVideoRepresentations(e,t){var s;let{storedSettings:r}=e.video;if(_(r))return;let{DEFAULT_VIDEO_REPRESENTATIONS_SWITCHING_MODE:i}=L.getCurrent(),o=this._getRepresentationsToLock(r.adaptation,t.representations),a=(s=t.switchingMode)!=null?s:i;r.lockedRepresentations.setValue({representationIds:o,switchingMode:a})}unlockAudioRepresentations(e){let{storedSettings:t}=e.audio;_(t)||t.lockedRepresentations.getValue()===null||t.lockedRepresentations.setValue(null)}unlockVideoRepresentations(e){let{storedSettings:t}=e.video;_(t)||t.lockedRepresentations.getValue()===null||t.lockedRepresentations.setValue(null)}dispose(){for(this._isDisposed=!0;;){let e=this._storedPeriodInfo.pop();if(e===void 0)return;e.isRemoved=!0}}_resetVideoTrackChoices(e){var r;for(let i=0;i<this._storedPeriodInfo.length;i++){let o=this._storedPeriodInfo[i];if(!_(o.video.storedSettings)){let a=o.video.storedSettings.adaptationBase;if(a!==null){let s=Va(a,this._isTrickModeTrackEnabled);o.video.storedSettings.adaptationBase=a,o.video.storedSettings.adaptation=s}}}let t=this._storedPeriodInfo.slice();for(let i=0;i<t.length;i++){let o=t[i].period,s=t[i].video.storedSettings;if(s!==void 0){if(this.trigger("trackUpdate",{period:Kt(o),trackType:"video",reason:e}),this._isDisposed)return;let d=ft(this._storedPeriodInfo,o.id);d!==void 0&&d.isPeriodAdvertised&&d.video.storedSettings===s&&((r=d.video.dispatcher)==null||r.updateTrack(s))}}}_removePeriodObject(e){y.CURRENT_ENV===y.DEV&&ee(e<this._storedPeriodInfo.length,"Invalid index for Period removal");let t=this._storedPeriodInfo[e];this._storedPeriodInfo[e].isRemoved=!0,this._storedPeriodInfo.splice(e,1),this._cachedPeriodInfo.set(t.period,t)}_getRepresentationsToLock(e,t){let r=t.reduce((i,o)=>{let a=Q(e.representations,s=>s.id===o);return a===void 0?m.warn("API: Wanted locked Representation not found."):i.push(a.id),i},[]);if(r.length===0)throw new Error("Cannot lock Representations: None of the given Representation id are found");return r}_selectInitialTrackIfNeeded(){var i,o,a,s;let{DEFAULT_VIDEO_TRACK_SWITCHING_MODE:e}=L.getCurrent(),t=[],r=[];for(let d of this._storedPeriodInfo){let{period:u}=d;if(d.audio.storedSettings!==void 0&&d.video.storedSettings!==void 0&&d.text.storedSettings!==void 0)continue;let c=[...(i=u.adaptations.audio)!=null?i:[],...(o=u.adaptations.video)!=null?o:[]],l=c.every(I=>I.supportStatus.hasCodecWithUndefinedSupport);if(c.length>0&&l)continue;let f=gt(u,"audio")[0];d.audio.storedSettings=f===void 0?null:{adaptation:f,switchingMode:this._defaultAudioTrackSwitchingMode,lockedRepresentations:new G(null)};let p=gt(u,"video")[0],g=Va(p,this._isTrickModeTrackEnabled);d.video.storedSettings=g===void 0?null:{adaptation:g,adaptationBase:p,switchingMode:e,lockedRepresentations:new G(null)};let b=null,h=((a=u.adaptations.text)!=null?a:[]).filter(I=>I.isForcedSubtitles===!0);if(h.length>0){if(f!=null){let I=Q(h,T=>T.normalizedLanguage===f.normalizedLanguage);I!==void 0&&(b=I)}b===null&&(b=(s=Q(h,I=>I.normalizedLanguage===void 0))!=null?s:null)}d.text.storedSettings=b===null?null:{adaptation:b,switchingMode:"direct",lockedRepresentations:new G(null)},r.push(d),this._shouldAdvertisePeriod(d)&&(d.isPeriodAdvertised=!0,t.push({id:u.id,start:u.start,end:u.end}))}if(!(t.length>0&&(this.trigger("newAvailablePeriods",t),this._isDisposed)))for(let d of r){if(!d.isPeriodAdvertised)continue;let u=["audio","video","text"];for(let c of u){let l=d[c];if(l.dispatcher!==null&&l.storedSettings!==void 0&&!l.dispatcher.hasSetTrack()&&(l.dispatcher.updateTrack(l.storedSettings),this._isDisposed))return}}}_shouldAdvertisePeriod(e){return!e.isPeriodAdvertised&&e.text.dispatcher!==null&&e.video.dispatcher!==null&&e.audio.dispatcher!==null}};function ft(n,e){for(let t=0;t<n.length;t++){let r=n[t];if(r.period.id===e)return r}}function Vl(n){var e,t,r;return!n.inManifest&&((e=n.text)==null?void 0:e.dispatcher)===null&&((t=n.audio)==null?void 0:t.dispatcher)===null&&((r=n.video)==null?void 0:r.dispatcher)===null}function Va(n,e){var t;return e&&((t=n.trickModeTracks)==null?void 0:t[0])!==void 0?n.trickModeTracks[0]:n}function zl(n,e){return{period:n,inManifest:e,isPeriodAdvertised:!1,isRemoved:!1,audio:{storedSettings:void 0,dispatcher:null},video:{storedSettings:void 0,dispatcher:null},text:{storedSettings:void 0,dispatcher:null}}}function Kt(n){return{start:n.start,end:n.end,id:n.id}}var hp=ho;function yp(n){let e,t,r,i,o,a,{DEFAULT_BASE_BANDWIDTH:s,DEFAULT_VIDEO_RESOLUTION_LIMIT:d,DEFAULT_MAX_BUFFER_AHEAD:u,DEFAULT_MAX_BUFFER_BEHIND:c,DEFAULT_MAX_VIDEO_BUFFER_SIZE:l,DEFAULT_THROTTLE_VIDEO_BITRATE_WHEN_HIDDEN:f,DEFAULT_WANTED_BUFFER_AHEAD:p}=L.getCurrent();if(_(n.maxBufferAhead))e=u;else if(e=Number(n.maxBufferAhead),isNaN(e))throw new Error("Invalid maxBufferAhead parameter. Should be a number.");if(_(n.maxBufferBehind))t=c;else if(t=Number(n.maxBufferBehind),isNaN(t))throw new Error("Invalid maxBufferBehind parameter. Should be a number.");if(_(n.wantedBufferAhead))r=p;else if(r=Number(n.wantedBufferAhead),isNaN(r))throw new Error("Invalid wantedBufferAhead parameter. Should be a number.");if(_(n.maxVideoBufferSize))i=l;else if(i=Number(n.maxVideoBufferSize),isNaN(i))throw new Error("Invalid maxVideoBufferSize parameter. Should be a number.");let g=_(n.videoResolutionLimit)?d:n.videoResolutionLimit,b=_(n.throttleVideoBitrateWhenHidden)?f:!!n.throttleVideoBitrateWhenHidden;if(_(n.videoElement))o=document.createElement("video");else if(n.videoElement.nodeName.toLowerCase()==="video"||n.videoElement.nodeName.toLowerCase()==="audio")o=n.videoElement;else throw new Error("Invalid videoElement parameter. Should be a HTMLMediaElement.");if(_(n.baseBandwidth))a=s;else if(a=Number(n.baseBandwidth),isNaN(a))throw new Error("Invalid baseBandwidth parameter. Should be a number.");return{maxBufferAhead:e,maxBufferBehind:t,videoResolutionLimit:g,videoElement:o,wantedBufferAhead:r,maxVideoBufferSize:i,throttleVideoBitrateWhenHidden:b,baseBandwidth:a}}function Ip(n){var e,t,r,i;if(n===null||typeof n!="object"&&n!==void 0)throw new Error("API: reload - Invalid options format.");if((n==null?void 0:n.reloadAt)===null||typeof(n==null?void 0:n.reloadAt)!="object"&&(n==null?void 0:n.reloadAt)!==void 0)throw new Error("API: reload - Invalid 'reloadAt' option format.");if(typeof((e=n==null?void 0:n.reloadAt)==null?void 0:e.position)!="number"&&((t=n==null?void 0:n.reloadAt)==null?void 0:t.position)!==void 0)throw new Error("API: reload - Invalid 'reloadAt.position' option format.");if(typeof((r=n==null?void 0:n.reloadAt)==null?void 0:r.relative)!="number"&&((i=n==null?void 0:n.reloadAt)==null?void 0:i.relative)!==void 0)throw new Error("API: reload - Invalid 'reloadAt.relative' option format.");if(!Array.isArray(n==null?void 0:n.keySystems)&&(n==null?void 0:n.keySystems)!==void 0)throw new Error("API: reload - Invalid 'keySystems' option format.");if((n==null?void 0:n.autoPlay)!==void 0&&typeof n.autoPlay!="boolean")throw new Error("API: reload - Invalid 'autoPlay' option format.")}function bp(n){var E,v,k,x;let e,t,r,i,o,a,s,{DEFAULT_AUTO_PLAY:d,DEFAULT_CODEC_SWITCHING_BEHAVIOR:u,DEFAULT_ENABLE_FAST_SWITCHING:c,DEFAULT_TEXT_TRACK_MODE:l}=L.getCurrent();if(_(n))throw new Error("No option set on loadVideo");if(!_(n.url))e=String(n.url);else if(_(n.initialManifest)&&_(n.manifestLoader))throw new Error("Unable to load a content: no url set on loadVideo.\nPlease provide at least either an `url` argument, a `initialManifest` option or a `manifestLoader` option so the RxPlayer can load the content.");if(_(n.transport))throw new Error("No transport set on loadVideo");t=String(n.transport);let f=_(n.autoPlay)?d:!!n.autoPlay;if(_(n.keySystems))r=[];else{r=Array.isArray(n.keySystems)?n.keySystems:[n.keySystems];for(let P of r)if(typeof P.type!="string"||typeof P.getLicense!="function")throw new Error("Invalid key system given: Missing type string or getLicense callback")}let p=n.lowLatencyMode===void 0?!1:!!n.lowLatencyMode,g=n.initialManifest,b=(E=n.minimumManifestUpdateInterval)!=null?E:0,h=(v=n.defaultAudioTrackSwitchingMode)!=null?v:void 0;h!==void 0&&!X(["seamless","direct","reload"],h)&&(m.warn("The `defaultAudioTrackSwitchingMode` loadVideo option must match one of the following strategy name:\n- `seamless`\n- `direct`\n- `reload`"),h=void 0);let I=_(n.onCodecSwitch)?u:n.onCodecSwitch;if(X(["continue","reload"],I)||(m.warn("The `onCodecSwitch` loadVideo option must match one of the following string:\n- `continue`\n- `reload`\nIf badly set, "+u+" will be used as default"),I=u),_(n.textTrackMode))i=l;else{if(n.textTrackMode!=="native"&&n.textTrackMode!=="html")throw new Error("Invalid textTrackMode.");i=n.textTrackMode}if(i==="html"){if(_(n.textTrackElement))throw new Error('You have to provide a textTrackElement in "html" textTrackMode.');if(n.textTrackElement instanceof HTMLElement)a=n.textTrackElement;else throw new Error("textTrackElement should be an HTMLElement.")}else _(n.textTrackElement)||m.warn('API: You have set a textTrackElement without being in an "html" textTrackMode. It will be ignored.');if(_(n.mode))o="auto";else{if(!X(["auto","multithread","main"],n.mode))throw new Error("Invalid `mode` option.");o=n.mode}let T=_(n.enableFastSwitching)?c:n.enableFastSwitching;if(!_(n.startAt))if("wallClockTime"in n.startAt&&n.startAt.wallClockTime instanceof Date){let P=n.startAt.wallClockTime.getTime()/1e3;s=Y({},n.startAt,{wallClockTime:P})}else s=n.startAt;let R=(k=n.requestConfig)!=null?k:{};return{__priv_patchLastSegmentInSidx:n.__priv_patchLastSegmentInSidx,__priv_manifestUpdateUrl:n.__priv_manifestUpdateUrl,checkMediaSegmentIntegrity:n.checkMediaSegmentIntegrity,checkManifestIntegrity:n.checkManifestIntegrity,autoPlay:f,defaultAudioTrackSwitchingMode:h,enableFastSwitching:T,initialManifest:g,keySystems:r,lowLatencyMode:p,manifestLoader:n.manifestLoader,minimumManifestUpdateInterval:b,requestConfig:R,onCodecSwitch:I,referenceDateTime:n.referenceDateTime,representationFilter:n.representationFilter,segmentLoader:n.segmentLoader,serverSyncInfos:n.serverSyncInfos,startAt:s,textTrackElement:a,textTrackMode:i,transport:t,mode:o,url:e,cmcd:n.cmcd,experimentalOptions:{enableRepresentationAvoidance:((x=n.experimentalOptions)==null?void 0:x.enableRepresentationAvoidance)===!0}}}function Sp(n,e,t,r){if(r.isCancelled())return;let i=n.getReference().getValue().seeking===2;i&&(e(),r.isCancelled())||n.listen(o=>{o.event==="seeking"?(i=!0,e()):i&&o.event==="seeked"&&(i=!1,t())},{includeLastObservation:!0,clearSignal:r})}function Tp(n,e,t,r){r.isCancelled()||n===null||(n.addEventListener("play",e),n.addEventListener("pause",t),r.register(()=>{n.removeEventListener("play",e),n.removeEventListener("pause",t)}))}function _p(n,e,t,r){let i=new G("LOADING",r);n.addEventListener("loaded",()=>{if(i.getValue()==="LOADING"){if(i.setValue("LOADED"),!r.isCancelled()){let s=Hl(e,null);s!=="PAUSED"&&i.setValue(s)}}else i.getValue()==="RELOADING"?i.setValue(Hl(e,null)):a(null)},r),n.addEventListener("reloadingMediaSource",()=>{mr(i.getValue())&&i.setValueIfChanged("RELOADING")},r);let o=null;return n.addEventListener("stalled",s=>{s!==o&&(a(s),o=s)},r),n.addEventListener("unstalled",()=>{o!==null&&(a(null),o=null)},r),t.listen(s=>{X(["seeking","ended","play","pause"],s.event)&&a(o)},{clearSignal:r}),i;function a(s){if(!mr(i.getValue()))return;let d=Hl(e,s);i.getValue()==="LOADED"&&d==="PAUSED"||i.setValueIfChanged(d)}}function Hl(n,e){let{FORCED_ENDED_THRESHOLD:t}=L.getCurrent();if(n.ended)return"ENDED";if(e!==null){let r=Math.abs(n.duration-n.currentTime);return!_(t)&&r<t?"ENDED":e==="seeking"?"SEEKING":e==="freezing"?"FREEZING":"BUFFERING"}return n.paused?"PAUSED":"PLAYING"}function mr(n){return n!=="LOADING"&&n!=="RELOADING"&&n!=="STOPPED"}var Kb=et(),Vb=["manifestLoader","segmentLoader"],Vt=class Vt extends ae{static get ErrorTypes(){return Ze}static get ErrorCodes(){return ls}static get LogLevel(){return m.getLevel()}static set LogLevel(e){m.setLevel(e,m.getFormat())}static get LogFormat(){return m.getFormat()}static set LogFormat(e){m.setLevel(m.getLevel(),e)}static addFeatures(e){ca(e)}static _priv_registerVideoElement(e){Vt._priv_currentlyUsedVideoElements.has(e)&&console.warn(`The video element is already attached to another RxPlayer instance.
|
|
18
|
-
Make sure to dispose the previous instance with player.dispose() before creating a new player instance attaching that video element.`),Vt._priv_currentlyUsedVideoElements.add(e)}static _priv_deregisterVideoElement(e){Vt._priv_currentlyUsedVideoElements.has(e)&&Vt._priv_currentlyUsedVideoElements.delete(e)}constructor(e={}){super();let{baseBandwidth:t,videoResolutionLimit:r,maxBufferAhead:i,maxBufferBehind:o,throttleVideoBitrateWhenHidden:a,videoElement:s,wantedBufferAhead:d,maxVideoBufferSize:u}=yp(e);s.preload="auto",this.version="4.3.1-dev.2025041000",this.log=m,this.state="STOPPED",this.videoElement=s,Vt._priv_registerVideoElement(this.videoElement);let c=new U;this._destroyCanceller=c,this._priv_pictureInPictureRef=Mc(s,c.signal),this._priv_speed=new G(s.playbackRate,this._destroyCanceller.signal),this._priv_preferTrickModeTracks=!1,this._priv_contentLock=new G(!1,this._destroyCanceller.signal),this._priv_bufferOptions={wantedBufferAhead:new G(d,this._destroyCanceller.signal),maxBufferAhead:new G(i,this._destroyCanceller.signal),maxBufferBehind:new G(o,this._destroyCanceller.signal),maxVideoBufferSize:new G(u,this._destroyCanceller.signal)},this._priv_bitrateInfos={lastBitrates:{audio:t,video:t}},this._priv_throttleVideoBitrateWhenHidden=a,this._priv_videoResolutionLimit=r,this._priv_currentError=null,this._priv_contentInfos=null,this._priv_contentEventsMemory={},this._priv_reloadingMetadata={},this._priv_lastAutoPlay=!1,this._priv_worker=null;let l=()=>{this.trigger("volumeChange",{volume:s.volume,muted:s.muted})};s.addEventListener("volumechange",l),c.signal.register(()=>{s.removeEventListener("volumechange",l)})}attachWorker(e){return new Promise((t,r)=>{var a;if(!Fl())return m.warn("API: Cannot rely on a WebWorker: Worker API unavailable"),r(new Un("INCOMPATIBLE_ERROR","Worker unavailable"));if(typeof e.workerUrl=="string")this._priv_worker=new Worker(e.workerUrl);else{let s=URL.createObjectURL(e.workerUrl);this._priv_worker=new Worker(s),URL.revokeObjectURL(s)}this._priv_worker.onerror=s=>{this._priv_worker!==null&&(this._priv_worker.terminate(),this._priv_worker=null),m.error("API: Unexpected worker error",s.error instanceof Error?s.error:void 0),r(new Un("UNKNOWN_ERROR",'Unexpected Worker "error" event'))};let i=s=>{let d=s.data;d.type==="init-error"?(m.warn("API: Processing InitError worker message: detaching worker"),this._priv_worker!==null&&(this._priv_worker.removeEventListener("message",i),this._priv_worker.terminate(),this._priv_worker=null),r(new Un("SETUP_ERROR","Worker parser initialization failed: "+d.value.errorMessage))):d.type==="init-success"&&(m.info("API: InitSuccess received from worker."),this._priv_worker!==null&&this._priv_worker.removeEventListener("message",i),t())};this._priv_worker.addEventListener("message",i),m.debug("---> Sending To Worker:","init"),this._priv_worker.postMessage({type:"init",value:{dashWasmUrl:e.dashWasmUrl,logLevel:m.getLevel(),logFormat:m.getFormat(),sendBackLogs:Bn(),date:Date.now(),timestamp:V(),hasVideo:((a=this.videoElement)==null?void 0:a.nodeName.toLowerCase())==="video"}}),m.addEventListener("onLogLevelChange",s=>{this._priv_worker!==null&&(m.debug("---> Sending To Worker:","log-level-update"),this._priv_worker.postMessage({type:"log-level-update",value:{logLevel:s.level,logFormat:s.format,sendBackLogs:Bn()}}))},this._destroyCanceller.signal);let o=s=>{this._priv_worker!==null&&(m.debug("---> Sending To Worker:","config-update"),this._priv_worker.postMessage({type:"config-update",value:s}))};L.updated&&o(L.getCurrent()),L.addEventListener("update",o,this._destroyCanceller.signal)})}getCurrentModeInformation(){return this._priv_contentInfos===null?null:{isDirectFile:this._priv_contentInfos.isDirectFile,useWorker:this._priv_contentInfos.useWorker}}addEventListener(e,t){return super.addEventListener(e,t)}stop(){this._priv_contentInfos!==null&&this._priv_contentInfos.currentContentCanceller.cancel(),this._priv_cleanUpCurrentContentState(),this.state!=="STOPPED"&&this._priv_setPlayerState("STOPPED")}dispose(){this.stop(),this.videoElement!==null&&(Vt._priv_deregisterVideoElement(this.videoElement),zn(this.videoElement).catch(e=>{let t=e instanceof Error?e.message:"Unknown error";m.error("API: Could not dispose decryption resources: "+t)})),this._destroyCanceller.cancel(),this._priv_reloadingMetadata={},this.videoElement=null,this._priv_worker!==null&&(this._priv_worker.terminate(),this._priv_worker=null)}loadVideo(e){let t=bp(e);m.info("API: Calling loadvideo",t.url,t.transport),this._priv_reloadingMetadata={options:t},this._priv_initializeContentPlayback(t),this._priv_lastAutoPlay=t.autoPlay}reload(e){var c,l,f;let{options:t,manifest:r,reloadPosition:i,reloadInPause:o}=this._priv_reloadingMetadata;if(t===void 0)throw new Error("API: Can't reload without having previously loaded a content.");Ip(e);let a;if(((c=e==null?void 0:e.reloadAt)==null?void 0:c.position)!==void 0)a={position:e.reloadAt.position};else if(((l=e==null?void 0:e.reloadAt)==null?void 0:l.relative)!==void 0){if(i===void 0)throw new Error("Can't reload to a relative position when previous content was not loaded.");a={position:e.reloadAt.relative+i}}else i!==void 0&&(a={position:i});let s;(e==null?void 0:e.autoPlay)!==void 0?s=e.autoPlay:o!==void 0&&(s=!o);let d;(e==null?void 0:e.keySystems)!==void 0?d=e.keySystems:((f=this._priv_reloadingMetadata.options)==null?void 0:f.keySystems)!==void 0&&(d=this._priv_reloadingMetadata.options.keySystems);let u=de(oe({},t),{initialManifest:r});a!==void 0&&(u.startAt=a),s!==void 0&&(u.autoPlay=s),d!==void 0&&(u.keySystems=d),this._priv_initializeContentPlayback(u)}createDebugElement(e){if(fe.createDebugElement===null)throw new Error("Feature `DEBUG_ELEMENT` not added to the RxPlayer");let t=new U;return fe.createDebugElement(e,this,t.signal),{dispose(){t.cancel()}}}getAvailableThumbnailTracks({time:e,periodId:t}={}){if(this._priv_contentInfos===null||this._priv_contentInfos.manifest===null)return[];let{manifest:r}=this._priv_contentInfos,i;if(e!==void 0){if(i=Vn(this._priv_contentInfos.manifest,e),i===void 0||i.thumbnailTracks.length===0)return[]}else if(t!==void 0){if(i=Q(r.periods,o=>o.id===t),i===void 0)return m.error("API: getAvailableThumbnailTracks: periodId not found"),[]}else{let{currentPeriod:o}=this._priv_contentInfos;if(o===null)return[];i=o}return i.thumbnailTracks.map(o=>({id:o.id,width:Math.floor(o.width/o.horizontalTiles),height:Math.floor(o.height/o.verticalTiles),mimeType:o.mimeType}))}async renderThumbnail(e){if(_(e.time))throw new Error("You have to provide a `time` property to `renderThumbnail`, indicating the wanted thumbnail time in seconds.");if(_(e.container))throw new Error("You have to provide a `container` property to `renderThumbnail`, specifying the HTML Element in which the thumbnail should be inserted.");return Kl(this._priv_contentInfos,e)}_priv_initializeContentPlayback(e){var q,ie,ne,le,be,me;let{autoPlay:t,cmcd:r,defaultAudioTrackSwitchingMode:i,enableFastSwitching:o,initialManifest:a,keySystems:s,lowLatencyMode:d,minimumManifestUpdateInterval:u,requestConfig:c,onCodecSwitch:l,startAt:f,transport:p,checkMediaSegmentIntegrity:g,checkManifestIntegrity:b,manifestLoader:h,referenceDateTime:I,segmentLoader:T,serverSyncInfos:R,mode:E,experimentalOptions:v,__priv_manifestUpdateUrl:k,__priv_patchLastSegmentInSidx:x,url:P}=e;if(this.videoElement===null)throw new Error("the attached video element is disposed");let M=p==="directfile",O=new U,B=this.videoElement,D,F=!1,A=null;if(M){if(fe.directfile===null)throw this.stop(),this._priv_currentError=null,new Error("DirectFile feature not activated in your build.");if(_(P))throw new Error("No URL for a DirectFile content");if(m.info("API: Initializing DirectFile mode in the main thread"),A=this._priv_initializeMediaElementTracksStore(O.signal),O.isUsed())return;D=new fe.directfile.initDirectFile({autoPlay:t,keySystems:s,speed:this._priv_speed,startAt:f,url:P})}else{let W={lowLatencyMode:d,maxRetry:(q=c.manifest)==null?void 0:q.maxRetry,requestTimeout:(ie=c.manifest)==null?void 0:ie.timeout,connectionTimeout:(ne=c.manifest)==null?void 0:ne.connectionTimeout,minimumManifestUpdateInterval:u,initialManifest:a},Ce=Bl(),nt={throttleBitrate:{},limitResolution:{}};this._priv_throttleVideoBitrateWhenHidden&&(Ce?nt.throttleBitrate={video:cn(Ac(this._priv_pictureInPictureRef,O.signal),Ht=>Ht?1/0:0,O.signal)}:m.warn("API: Can't apply throttleVideoBitrateWhenHidden because browser can't be trusted for visibility.")),this._priv_videoResolutionLimit==="videoElement"?Ce?nt.limitResolution={video:wc(B,this._priv_pictureInPictureRef,O.signal)}:m.warn("API: Can't apply videoResolutionLimit because browser can't be trusted for video size."):this._priv_videoResolutionLimit==="screen"&&(nt.limitResolution={video:xc(O.signal)});let Ae={initialBitrates:this._priv_bitrateInfos.lastBitrates,lowLatencyMode:d,throttlers:nt},zt=e.textTrackMode==="native"?{textTrackMode:"native"}:{textTrackMode:"html",textTrackElement:e.textTrackElement},ln=Y({enableFastSwitching:o,onCodecSwitch:l},this._priv_bufferOptions),mt={lowLatencyMode:d,maxRetry:(le=c.segment)==null?void 0:le.maxRetry,requestTimeout:(be=c.segment)==null?void 0:be.timeout,connectionTimeout:(me=c.segment)==null?void 0:me.connectionTimeout},St=fe.multithread!==null&&this._priv_worker!==null&&p==="dash"&&Vb.every(Ht=>_(e[Ht]))&&typeof e.representationFilter!="function";if(E==="main"||E==="auto"&&!St){if(fe.mainThreadMediaSourceInit===null)throw new Error("Cannot load video, neither in a WebWorker nor with the `MEDIA_SOURCE_MAIN` feature");let Ht=fe.transports[p];if(typeof Ht!="function")throw this.stop(),this._priv_currentError=null,new Error(`transport "${p}" not supported`);let vp=typeof e.representationFilter=="string"?kc(e.representationFilter):e.representationFilter;m.info("API: Initializing MediaSource mode in the main thread");let Rp=Ht({lowLatencyMode:d,checkMediaSegmentIntegrity:g,checkManifestIntegrity:b,manifestLoader:h,referenceDateTime:I,representationFilter:vp,segmentLoader:T,serverSyncInfos:R,__priv_manifestUpdateUrl:k,__priv_patchLastSegmentInSidx:x});D=new fe.mainThreadMediaSourceInit({adaptiveOptions:Ae,autoPlay:t,bufferOptions:ln,cmcd:r,enableRepresentationAvoidance:v.enableRepresentationAvoidance,keySystems:s,lowLatencyMode:d,transport:Rp,manifestRequestSettings:W,segmentRequestOptions:mt,speed:this._priv_speed,startAt:f,textTrackOptions:zt,url:P})}else{if(fe.multithread===null)throw new Error("Cannot load video in multithread mode: `MULTI_THREAD` feature not imported.");if(this._priv_worker===null)throw new Error("Cannot load video in multithread mode: `attachWorker` method not called.");ee(typeof e.representationFilter!="function"),F=!0,m.info("API: Initializing MediaSource mode in a WebWorker");let Ht={lowLatencyMode:d,checkMediaSegmentIntegrity:g,checkManifestIntegrity:b,referenceDateTime:I,serverSyncInfos:R,manifestLoader:void 0,segmentLoader:void 0,representationFilter:e.representationFilter,__priv_manifestUpdateUrl:k,__priv_patchLastSegmentInSidx:x};D=new fe.multithread.init({adaptiveOptions:Ae,autoPlay:t,bufferOptions:ln,cmcd:r,enableRepresentationAvoidance:v.enableRepresentationAvoidance,keySystems:s,lowLatencyMode:d,transportOptions:Ht,manifestRequestSettings:W,segmentRequestOptions:mt,speed:this._priv_speed,startAt:f,textTrackOptions:zt,worker:this._priv_worker,url:P,useMseInWorker:cm})}}let C={contentId:Kb(),originalUrl:P,currentContentCanceller:O,defaultAudioTrackSwitchingMode:i,initializer:D,isDirectFile:M,manifest:null,currentPeriod:null,activeAdaptations:null,activeRepresentations:null,tracksStore:null,mediaElementTracksStore:A,useWorker:F,segmentSinkMetricsCallback:null,fetchThumbnailDataCallback:null,thumbnailRequestsInfo:{pendingRequests:new WeakMap,lastResponse:null}};D.addEventListener("error",W=>{this._priv_onFatalError(W,C)}),D.addEventListener("warning",W=>{let Ce=Ee(W,{defaultCode:"NONE",defaultReason:"An unknown error happened."});m.warn("API: Sending warning:",Ce),this.trigger("warning",Ce)}),D.addEventListener("reloadingMediaSource",W=>{C.tracksStore!==null&&C.tracksStore.resetPeriodObjects(),this._priv_contentInfos!==null&&(this._priv_contentInfos.segmentSinkMetricsCallback=null),this._priv_lastAutoPlay=W.autoPlay}),D.addEventListener("inbandEvents",W=>this.trigger("inbandEvents",W)),D.addEventListener("streamEvent",W=>this.trigger("streamEvent",W)),D.addEventListener("streamEventSkip",W=>this.trigger("streamEventSkip",W)),D.addEventListener("activePeriodChanged",W=>this._priv_onActivePeriodChanged(C,W)),D.addEventListener("periodStreamReady",W=>this._priv_onPeriodStreamReady(C,W)),D.addEventListener("periodStreamCleared",W=>this._priv_onPeriodStreamCleared(C,W)),D.addEventListener("representationChange",W=>this._priv_onRepresentationChange(C,W)),D.addEventListener("adaptationChange",W=>this._priv_onAdaptationChange(C,W)),D.addEventListener("bitrateEstimateChange",W=>this._priv_onBitrateEstimateChange(W)),D.addEventListener("manifestReady",W=>this._priv_onManifestReady(C,W)),D.addEventListener("manifestUpdate",W=>this._priv_onManifestUpdate(C,W)),D.addEventListener("codecSupportUpdate",()=>this._priv_onCodecSupportUpdate(C)),D.addEventListener("decipherabilityUpdate",W=>this._priv_onDecipherabilityUpdate(C,W)),D.addEventListener("loaded",W=>{this._priv_contentInfos!==null&&(this._priv_contentInfos.segmentSinkMetricsCallback=W.getSegmentSinkMetrics,this._priv_contentInfos.fetchThumbnailDataCallback=W.getThumbnailData)}),D.prepare(),this.stop();let N=new po(B,{withMediaSource:!M,lowLatencyMode:d});O.signal.register(()=>{N.stop()});let K=_p(D,B,N,O.signal);O.signal.register(()=>{D.dispose()});let j=W=>{switch(W){case"STOPPED":case"RELOADING":case"LOADING":break;case"ENDED":this._priv_reloadingMetadata.reloadInPause=!0,this._priv_reloadingMetadata.reloadPosition=N.getReference().getValue().position.getPolled();break;default:{let Ce=N.getReference().getValue();this._priv_reloadingMetadata.reloadInPause=Ce.paused,this._priv_reloadingMetadata.reloadPosition=Ce.position.getWanted();break}}},$=null,z=W=>{$!==null&&($.cancel(),$=null),K.onUpdate((Ce,nt)=>{mr(Ce)&&(nt(),$!==null&&$.cancel(),$=new U,$.linkToSignal(O.signal),W!==!B.paused&&(B.paused?this.trigger("pause",null):this.trigger("play",null)),Tp(B,()=>this.trigger("play",null),()=>this.trigger("pause",null),O.signal))},{emitCurrentValue:!1,clearSignal:O.signal})};z(t),D.addEventListener("reloadingMediaSource",W=>{z(W.autoPlay)}),this._priv_currentError=null,this._priv_contentInfos=C;let H=null;K.onUpdate(W=>{j(W),this._priv_setPlayerState(W),!O.isUsed()&&(H!==null?mr(this.state)||(H.cancel(),H=null):mr(this.state)&&(H=new U,H.linkToSignal(O.signal),Sp(N,()=>this.trigger("seeking",null),()=>this.trigger("seeked",null),H.signal)))},{emitCurrentValue:!0,clearSignal:O.signal}),N.listen(W=>{j(this.state),this._priv_triggerPositionUpdate(C,W)},{clearSignal:O.signal}),O.signal.register(()=>{D.removeEventListener()}),this._priv_contentLock.onUpdate((W,Ce)=>{W||(Ce(),D.start(B,N))},{emitCurrentValue:!0,clearSignal:O.signal})}getError(){return this._priv_currentError}getVideoElement(){return this.videoElement}getPlayerState(){return this.state}isContentLoaded(){return!X(["LOADING","RELOADING","STOPPED"],this.state)}isBuffering(){return X(["BUFFERING","SEEKING","LOADING","RELOADING"],this.state)}isPaused(){return this.videoElement!==null?X(["LOADING","RELOADING"],this.state)?!this._priv_lastAutoPlay:this.videoElement.paused:!0}isLive(){if(this._priv_contentInfos===null)return!1;let{isDirectFile:e,manifest:t}=this._priv_contentInfos;return e||t===null?!1:t.isLive}areTrickModeTracksEnabled(){return this._priv_preferTrickModeTracks}getContentUrls(){if(this._priv_contentInfos===null)return;let{isDirectFile:e,manifest:t,originalUrl:r}=this._priv_contentInfos;if(e)return r===void 0?void 0:[r];if(t!==null)return t.uris}updateContentUrls(e,t){if(this._priv_contentInfos===null)throw new Error("No content loaded");let r=(t==null?void 0:t.refresh)===!0;this._priv_contentInfos.initializer.updateContentUrls(e,r)}getMediaDuration(){if(this.videoElement===null)throw new Error("Disposed player");return this.videoElement.duration}getCurrentBufferGap(){if(this.videoElement===null)throw new Error("Disposed player");let e=this.videoElement,t=uc(e.buffered,e.currentTime);return t===1/0?0:t}getWallClockTime(){var r;if(this.videoElement===null)throw new Error("Disposed player");if(this._priv_contentInfos===null)return this.videoElement.currentTime;let{isDirectFile:e,manifest:t}=this._priv_contentInfos;if(e){let i=mo(this.videoElement);return(i!=null?i:0)+this.videoElement.currentTime}if(t!==null){let i=this.videoElement.currentTime,o=(r=t.availabilityStartTime)!=null?r:0;return i+o}return 0}getPosition(){if(this.videoElement===null)throw new Error("Disposed player");return this.videoElement.currentTime}getLastStoredContentPosition(){return this._priv_reloadingMetadata.reloadPosition}getPlaybackRate(){return this._priv_speed.getValue()}setPlaybackRate(e,t){var o;e!==this._priv_speed.getValue()&&this._priv_speed.setValue(e);let r=t==null?void 0:t.preferTrickModeTracks;if(typeof r!="boolean")return;this._priv_preferTrickModeTracks=r;let i=(o=this._priv_contentInfos)==null?void 0:o.tracksStore;_(i)||(r&&!i.isTrickModeEnabled()?i.enableVideoTrickModeTracks():!r&&i.isTrickModeEnabled()&&i.disableVideoTrickModeTracks())}getVideoRepresentation(){let e=this.__priv_getCurrentRepresentations();if(e!==null)return e.video}getAudioRepresentation(){let e=this.__priv_getCurrentRepresentations();if(e!==null)return e.audio}play(){if(this.videoElement===null)throw new Error("Disposed player");let e=this.videoElement.play();return _(e)||typeof e.catch!="function"?Promise.resolve():e.catch(t=>{if(t.name==="NotAllowedError"){let r=new te("MEDIA_ERR_PLAY_NOT_ALLOWED",t.toString());this.trigger("warning",r)}throw t})}pause(){if(this.videoElement===null)throw new Error("Disposed player");this.videoElement.pause()}seekTo(e){var o;if(this.videoElement===null)throw new Error("Disposed player");if(this._priv_contentInfos===null)throw new Error("player: no content loaded");let{isDirectFile:t,manifest:r}=this._priv_contentInfos;if(!t&&r===null)throw new Error("player: the content did not load yet");let i;if(typeof e=="number")i=e;else if(typeof e=="object"){let a=e,s=this.videoElement.currentTime;if(!_(a.relative))i=s+a.relative;else if(!_(a.position))i=a.position;else{if(_(a.wallClockTime))throw new Error('invalid time object. You must set one of the following properties: "relative", "position" or "wallClockTime"');if(r!==null)i=a.wallClockTime-((o=r.availabilityStartTime)!=null?o:0);else if(t&&this.videoElement!==null){let d=mo(this.videoElement);d!==void 0&&(i=a.wallClockTime-d)}i===void 0&&(i=a.wallClockTime)}}if(i===void 0)throw new Error("invalid time given");return m.info("API: API Seek to",i),this.videoElement.currentTime=i,i}getVolume(){if(this.videoElement===null)throw new Error("Disposed player");return this.videoElement.volume}setVolume(e){if(this.videoElement===null)throw new Error("Disposed player");let t=this.videoElement;e!==t.volume&&(t.volume=e)}isMute(){var e;return((e=this.videoElement)==null?void 0:e.muted)===!0}mute(){if(this.videoElement===null)throw new Error("Disposed player");this.videoElement.muted||(this.videoElement.muted=!0)}unMute(){if(this.videoElement===null)throw new Error("Disposed player");this.videoElement.muted&&(this.videoElement.muted=!1)}setMaxBufferBehind(e){this._priv_bufferOptions.maxBufferBehind.setValue(e)}setMaxBufferAhead(e){this._priv_bufferOptions.maxBufferAhead.setValue(e)}setWantedBufferAhead(e){this._priv_bufferOptions.wantedBufferAhead.setValue(e)}setMaxVideoBufferSize(e){this._priv_bufferOptions.maxVideoBufferSize.setValue(e)}getMaxBufferBehind(){return this._priv_bufferOptions.maxBufferBehind.getValue()}getMaxBufferAhead(){return this._priv_bufferOptions.maxBufferAhead.getValue()}getWantedBufferAhead(){return this._priv_bufferOptions.wantedBufferAhead.getValue()}getMaxVideoBufferSize(){return this._priv_bufferOptions.maxVideoBufferSize.getValue()}getCurrentPeriod(){var t;let e=(t=this._priv_contentInfos)==null?void 0:t.currentPeriod;return _(e)?null:{id:e.id,start:e.start,end:e.end}}getKeySystemConfiguration(){if(this.videoElement===null)throw new Error("Disposed player");let e=$n(this.videoElement);return e===null?null:{keySystem:e[0],configuration:e[1]}}getAvailablePeriods(){if(this._priv_contentInfos===null)return[];let{isDirectFile:e,tracksStore:t}=this._priv_contentInfos;return e?[]:t===null?[]:t.getAvailablePeriods().slice()}getAvailableAudioTracks(e){var a,s;if(this._priv_contentInfos===null)return[];let{isDirectFile:t,mediaElementTracksStore:r}=this._priv_contentInfos;if(t)return(a=r==null?void 0:r.getAvailableAudioTracks())!=null?a:[];let i,o=!0;return typeof e=="string"?i=e:(i=e==null?void 0:e.periodId,o=(s=e==null?void 0:e.filterPlayableRepresentations)!=null?s:!0),this._priv_callTracksStoreGetterSetter(i,[],(d,u)=>{var c;return(c=d.getAvailableAudioTracks(u,o))!=null?c:[]})}getAvailableTextTracks(e){var i;if(this._priv_contentInfos===null)return[];let{isDirectFile:t,mediaElementTracksStore:r}=this._priv_contentInfos;return t?(i=r==null?void 0:r.getAvailableTextTracks())!=null?i:[]:this._priv_callTracksStoreGetterSetter(e,[],(o,a)=>{var s;return(s=o.getAvailableTextTracks(a))!=null?s:[]})}getAvailableVideoTracks(e){var a,s;if(this._priv_contentInfos===null)return[];let{isDirectFile:t,mediaElementTracksStore:r}=this._priv_contentInfos;if(t)return(a=r==null?void 0:r.getAvailableVideoTracks())!=null?a:[];let i,o=!0;return typeof e=="string"?i=e:(i=e==null?void 0:e.periodId,o=(s=e==null?void 0:e.filterPlayableRepresentations)!=null?s:!0),this._priv_callTracksStoreGetterSetter(i,[],(d,u)=>{var c;return(c=d.getAvailableVideoTracks(u,o))!=null?c:[]})}getAudioTrack(e){var a;if(this._priv_contentInfos===null)return;let{isDirectFile:t,mediaElementTracksStore:r}=this._priv_contentInfos;if(t)return r===null?void 0:r.getChosenAudioTrack();let i,o=!0;return typeof e=="string"?i=e:(i=e==null?void 0:e.periodId,o=(a=e==null?void 0:e.filterPlayableRepresentations)!=null?a:!0),this._priv_callTracksStoreGetterSetter(i,void 0,(s,d)=>s.getChosenAudioTrack(d,o))}getTextTrack(e){if(this._priv_contentInfos===null)return;let{isDirectFile:t,mediaElementTracksStore:r}=this._priv_contentInfos;return t?r===null?void 0:r.getChosenTextTrack():this._priv_callTracksStoreGetterSetter(e,void 0,(i,o)=>i.getChosenTextTrack(o))}getVideoTrack(e){var a;if(this._priv_contentInfos===null)return;let{isDirectFile:t,mediaElementTracksStore:r}=this._priv_contentInfos;if(t)return r===null?void 0:r.getChosenVideoTrack();let i,o=!0;return typeof e=="string"?i=e:(i=e==null?void 0:e.periodId,o=(a=e==null?void 0:e.filterPlayableRepresentations)!=null?a:!0),this._priv_callTracksStoreGetterSetter(i,void 0,(s,d)=>s.getChosenVideoTrack(d,o))}setAudioTrack(e){var u;if(this._priv_contentInfos===null)throw new Error("No content loaded");let{isDirectFile:t,mediaElementTracksStore:r}=this._priv_contentInfos;if(t)try{let c=typeof e=="string"?e:e.trackId;r==null||r.setAudioTrackById(c);return}catch(c){throw new Error("player: unknown audio track")}let i,o,a,s=null,d;return typeof e=="string"?o=e:(o=e.trackId,i=e.periodId,a=e.switchingMode,s=(u=e.lockedRepresentations)!=null?u:null,d=e.relativeResumingPosition),this._priv_callTracksStoreGetterSetter(i,void 0,(c,l)=>c.setAudioTrack({periodRef:l,trackId:o,switchingMode:a,lockedRepresentations:s,relativeResumingPosition:d}))}setTextTrack(e){if(this._priv_contentInfos===null)throw new Error("No content loaded");let{isDirectFile:t,mediaElementTracksStore:r}=this._priv_contentInfos;if(t)try{let a=typeof e=="string"?e:e.trackId;r==null||r.setTextTrackById(a);return}catch(a){throw new Error("player: unknown text track")}let i,o;return typeof e=="string"?o=e:(o=e.trackId,i=e.periodId),this._priv_callTracksStoreGetterSetter(i,void 0,(a,s)=>a.setTextTrack(s,o))}disableTextTrack(e){if(this._priv_contentInfos===null)return;let{isDirectFile:t,mediaElementTracksStore:r}=this._priv_contentInfos;if(t){r==null||r.disableTextTrack();return}return this._priv_callTracksStoreGetterSetter(e,void 0,(i,o)=>i.disableTrack(o,"text"))}setVideoTrack(e){var u;if(this._priv_contentInfos===null)throw new Error("No content loaded");let{isDirectFile:t,mediaElementTracksStore:r}=this._priv_contentInfos;if(t)try{let c=typeof e=="string"?e:e.trackId;r==null||r.setVideoTrackById(c);return}catch(c){throw new Error("player: unknown video track")}let i,o,a,s=null,d;return typeof e=="string"?o=e:(o=e.trackId,i=e.periodId,a=e.switchingMode,s=(u=e.lockedRepresentations)!=null?u:null,d=e.relativeResumingPosition),this._priv_callTracksStoreGetterSetter(i,void 0,(c,l)=>c.setVideoTrack({periodRef:l,trackId:o,switchingMode:a,lockedRepresentations:s,relativeResumingPosition:d}))}disableVideoTrack(e){if(this._priv_contentInfos===null)return;let{isDirectFile:t,mediaElementTracksStore:r}=this._priv_contentInfos;return t&&r!==null?r.disableVideoTrack():this._priv_callTracksStoreGetterSetter(e,void 0,(i,o)=>i.disableTrack(o,"video"))}lockVideoRepresentations(e){if(this._priv_contentInfos===null)throw new Error("No content loaded");let{isDirectFile:t}=this._priv_contentInfos;if(t)throw new Error("Cannot lock video Representations in directfile mode.");let r,i,o;return Array.isArray(e)?(r=e,i=void 0):(r=e.representations,i=e.periodId,o=e.switchingMode),this._priv_callTracksStoreGetterSetter(i,void 0,(a,s)=>a.lockVideoRepresentations(s,{representations:r,switchingMode:o}))}lockAudioRepresentations(e){if(this._priv_contentInfos===null)throw new Error("No content loaded");let{isDirectFile:t}=this._priv_contentInfos;if(t)throw new Error("Cannot lock audio Representations in directfile mode.");let r,i,o;return Array.isArray(e)?(r=e,i=void 0):(r=e.representations,i=e.periodId,o=e.switchingMode),this._priv_callTracksStoreGetterSetter(i,void 0,(a,s)=>a.lockAudioRepresentations(s,{representations:r,switchingMode:o}))}getLockedVideoRepresentations(e){if(this._priv_contentInfos===null)return null;let{isDirectFile:t}=this._priv_contentInfos;return t?null:this._priv_callTracksStoreGetterSetter(e,null,(r,i)=>r.getLockedVideoRepresentations(i))}getLockedAudioRepresentations(e){if(this._priv_contentInfos===null)return null;let{isDirectFile:t}=this._priv_contentInfos;return t?null:this._priv_callTracksStoreGetterSetter(e,null,(r,i)=>r.getLockedAudioRepresentations(i))}unlockVideoRepresentations(e){if(this._priv_contentInfos===null)return;let{isDirectFile:t}=this._priv_contentInfos;if(!t)return this._priv_callTracksStoreGetterSetter(e,void 0,(r,i)=>r.unlockVideoRepresentations(i))}unlockAudioRepresentations(e){if(this._priv_contentInfos===null)return;let{isDirectFile:t}=this._priv_contentInfos;if(!t)return this._priv_callTracksStoreGetterSetter(e,void 0,(r,i)=>r.unlockAudioRepresentations(i))}getMinimumPosition(){if(this._priv_contentInfos===null)return null;if(this._priv_contentInfos.isDirectFile)return 0;let{manifest:e}=this._priv_contentInfos;return e!==null?In(e):null}getLivePosition(){if(this._priv_contentInfos===null)return null;let{isDirectFile:e,manifest:t}=this._priv_contentInfos;if(!e)return(t==null?void 0:t.isLive)!==!0?null:bn(t)}getMaximumPosition(){if(this._priv_contentInfos===null)return null;let{isDirectFile:e,manifest:t}=this._priv_contentInfos;if(e){if(this.videoElement===null)throw new Error("Disposed player");return this.videoElement.duration}return t!==null?!t.isDynamic&&this.videoElement!==null?this.videoElement.duration:_t(t):null}async __priv_getSegmentSinkMetrics(){var e,t;return(t=(e=this._priv_contentInfos)==null?void 0:e.segmentSinkMetricsCallback)==null?void 0:t.call(e)}__priv_getManifest(){return this._priv_contentInfos===null?null:this._priv_contentInfos.manifest}__priv_getCurrentAdaptation(){if(this._priv_contentInfos===null)return null;let{currentPeriod:e,activeAdaptations:t}=this._priv_contentInfos;return e===null||t===null||_(t[e.id])?null:t[e.id]}__priv_getCurrentRepresentations(){if(this._priv_contentInfos===null)return null;let{currentPeriod:e,activeRepresentations:t}=this._priv_contentInfos;return e===null||t===null||_(t[e.id])?null:t[e.id]}_priv_cleanUpCurrentContentState(){var t,r,i,o;m.debug("Locking `contentLock` to clean-up the current content."),this._priv_contentLock.setValue(!0),(r=(t=this._priv_contentInfos)==null?void 0:t.tracksStore)==null||r.dispose(),(o=(i=this._priv_contentInfos)==null?void 0:i.mediaElementTracksStore)==null||o.dispose(),this._priv_contentInfos=null,this._priv_contentEventsMemory={};let e=()=>{this.videoElement!==null&&(m.debug("Unlocking `contentLock`. Next content can begin."),this._priv_contentLock.setValue(!1))};_(this.videoElement)?e():wo(this.videoElement).then(()=>{m.debug("API: DRM session cleaned-up with success!"),e()},a=>{m.error("API: An error arised when trying to clean-up the DRM session:"+(a instanceof Error?a.toString():"Unknown Error")),e()})}_priv_onManifestReady(e,t){var i;if(e.contentId!==((i=this._priv_contentInfos)==null?void 0:i.contentId))return;e.manifest=t,t.manifestFormat===0&&(this._priv_reloadingMetadata.manifest=t);let r=new hp({preferTrickModeTracks:this._priv_preferTrickModeTracks,defaultAudioTrackSwitchingMode:e.defaultAudioTrackSwitchingMode});e.tracksStore=r,r.addEventListener("newAvailablePeriods",o=>{this.trigger("newAvailablePeriods",o)}),r.addEventListener("brokenRepresentationsLock",o=>{this.trigger("brokenRepresentationsLock",o)}),r.addEventListener("trackUpdate",o=>{var s,d;this.trigger("trackUpdate",o);let a=(d=(s=this._priv_contentInfos)==null?void 0:s.currentPeriod)!=null?d:void 0;o.reason==="no-playable-representation"&&o.period.id===(a==null?void 0:a.id)&&this._priv_onAvailableTracksMayHaveChanged(o.trackType)}),e.tracksStore.addEventListener("warning",o=>{this.trigger("warning",o)}),e.tracksStore.addEventListener("error",o=>{this._priv_onFatalError(o,e)}),e.tracksStore.onManifestUpdate(t)}_priv_onManifestUpdate(e,t){var o,a,s;if(this._priv_contentInfos===null||this._priv_contentInfos.manifest===null)return;_(e==null?void 0:e.tracksStore)||e.tracksStore.onManifestUpdate(this._priv_contentInfos.manifest);let r=(a=(o=this._priv_contentInfos)==null?void 0:o.currentPeriod)!=null?a:void 0,i=(s=this._priv_contentInfos)==null?void 0:s.tracksStore;if(!(r===void 0||_(i))){for(let d of t.updatedPeriods)if(d.period.id===r.id&&(d.result.addedAdaptations.length>0||d.result.removedAdaptations.length>0)){if(i.getPeriodObjectFromPeriod(r)===void 0)return;this._priv_onAvailableTracksMayHaveChanged("audio"),this._priv_onAvailableTracksMayHaveChanged("text"),this._priv_onAvailableTracksMayHaveChanged("video")}}}_priv_onCodecSupportUpdate(e){let t=e==null?void 0:e.tracksStore;_(t)||t.onManifestCodecSupportUpdate()}_priv_onDecipherabilityUpdate(e,t){if(e===null||e.manifest===null)return;_(e==null?void 0:e.tracksStore)||e.tracksStore.onDecipherabilityUpdates();let r=t.reduce((i,o)=>{var s,d,u;if(!(Q(i,c=>c[0].id===o.period.id&&c[1]===o.adaptation.type)!==void 0)){let c=e.tracksStore;if(c===null)return i;let l=!1,f=c.getPeriodObjectFromPeriod(o.period);if(f===void 0)return i;switch(o.adaptation.type){case"audio":l=((s=c.getChosenAudioTrack(f,!1))==null?void 0:s.id)===o.adaptation.id;break;case"video":l=((d=c.getChosenVideoTrack(f,!1))==null?void 0:d.id)===o.adaptation.id;break;case"text":l=((u=c.getChosenTextTrack(f))==null?void 0:u.id)===o.adaptation.id;break}l&&i.push([o.period,o.adaptation.type])}return i},[]);for(let[i,o]of r)this._priv_triggerEventIfNotStopped("representationListUpdate",{period:{start:i.start,end:i.end,id:i.id},trackType:o,reason:"decipherability-update"},e.currentContentCanceller.signal)}_priv_onActivePeriodChanged(e,{period:t}){var s,d,u,c,l,f;if(e.contentId!==((s=this._priv_contentInfos)==null?void 0:s.contentId))return;e.currentPeriod=t;let r=e.currentContentCanceller.signal;this._priv_contentEventsMemory.periodChange!==t&&(this._priv_contentEventsMemory.periodChange=t,this._priv_triggerEventIfNotStopped("periodChange",{start:t.start,end:t.end,id:t.id},r)),this._priv_triggerEventIfNotStopped("availableAudioTracksChange",this.getAvailableAudioTracks(),r),this._priv_triggerEventIfNotStopped("availableTextTracksChange",this.getAvailableTextTracks(),r),this._priv_triggerEventIfNotStopped("availableVideoTracksChange",this.getAvailableVideoTracks(),r);let i=(d=this._priv_contentInfos)==null?void 0:d.tracksStore;if(_(i))this._priv_triggerEventIfNotStopped("audioTrackChange",null,r),this._priv_triggerEventIfNotStopped("textTrackChange",null,r),this._priv_triggerEventIfNotStopped("videoTrackChange",null,r);else{let p=i.getPeriodObjectFromPeriod(t);if(p!==void 0){let g=i.getChosenAudioTrack(p,!0);this._priv_triggerEventIfNotStopped("audioTrackChange",g,r);let b=i.getChosenTextTrack(p);this._priv_triggerEventIfNotStopped("textTrackChange",b,r);let h=i.getChosenVideoTrack(p,!0);this._priv_triggerEventIfNotStopped("videoTrackChange",h,r)}}let o=(c=(u=this.__priv_getCurrentRepresentations())==null?void 0:u.audio)!=null?c:null;this._priv_triggerEventIfNotStopped("audioRepresentationChange",o,r);let a=(f=(l=this.__priv_getCurrentRepresentations())==null?void 0:l.video)!=null?f:null;this._priv_triggerEventIfNotStopped("videoRepresentationChange",a,r)}_priv_onPeriodStreamReady(e,t){var s;if(e.contentId!==((s=this._priv_contentInfos)==null?void 0:s.contentId))return;let{type:r,period:i,adaptationRef:o}=t,a=e.tracksStore;switch(r){case"video":case"audio":case"text":_(a)?(m.error(`API: TracksStore not instanciated for a new ${r} period`),o.setValue(null)):a.addTrackReference(r,i,o);break;default:He(r)}}_priv_onPeriodStreamCleared(e,t){var d;if(e.contentId!==((d=this._priv_contentInfos)==null?void 0:d.contentId))return;let{type:r,periodId:i}=t,o=e.tracksStore;switch(r){case"audio":case"text":case"video":_(o)||o.removeTrackReference(r,i);break}let{activeAdaptations:a,activeRepresentations:s}=e;if(!_(a)&&!_(a[i])){let u=a[i];delete u[r],Object.keys(u).length===0&&delete a[i]}if(!_(s)&&!_(s[i])){let u=s[i];delete u[r],Object.keys(u).length===0&&delete s[i]}}_priv_onAdaptationChange(e,{type:t,adaptation:r,period:i}){var c;if(e.contentId!==((c=this._priv_contentInfos)==null?void 0:c.contentId))return;e.activeAdaptations===null&&(e.activeAdaptations={});let{activeAdaptations:o,currentPeriod:a}=e,s=o[i.id];_(s)?o[i.id]={[t]:r}:s[t]=r;let{tracksStore:d}=e,u=e.currentContentCanceller.signal;if(d!==null&&a!==null&&!_(i)&&i.id===a.id){let l=d.getPeriodObjectFromPeriod(i);if(l===void 0)return;switch(t){case"audio":{let f=d.getChosenAudioTrack(l,!0);this._priv_triggerEventIfNotStopped("audioTrackChange",f,u);break}case"text":{let f=d.getChosenTextTrack(l);this._priv_triggerEventIfNotStopped("textTrackChange",f,u);break}case"video":{let f=d.getChosenVideoTrack(l,!0);this._priv_triggerEventIfNotStopped("videoTrackChange",f,u);break}}}}_priv_onRepresentationChange(e,{type:t,period:r,representation:i}){var d;if(e.contentId!==((d=this._priv_contentInfos)==null?void 0:d.contentId))return;e.activeRepresentations===null&&(e.activeRepresentations={});let{activeRepresentations:o,currentPeriod:a}=e,s=o[r.id];if(_(s)?o[r.id]={[t]:i}:s[t]=i,!_(r)&&a!==null&&a.id===r.id){let u=this._priv_contentInfos.currentContentCanceller.signal;t==="video"?this._priv_triggerEventIfNotStopped("videoRepresentationChange",i,u):t==="audio"&&this._priv_triggerEventIfNotStopped("audioRepresentationChange",i,u)}}_priv_onBitrateEstimateChange({type:e,bitrate:t}){t!==void 0&&(this._priv_bitrateInfos.lastBitrates[e]=t),this.trigger("__priv_bitrateEstimateChange",{type:e,bitrate:t})}_priv_setPlayerState(e){this.state!==e&&(this.state=e,m.info("API: playerStateChange event",e),this.trigger("playerStateChange",e))}_priv_triggerPositionUpdate(e,t){var s,d;if(e.contentId!==((s=this._priv_contentInfos)==null?void 0:s.contentId))return;let{isDirectFile:r,manifest:i}=e;if(!r&&i===null||_(t))return;let o=i!==null?_t(i):void 0,a={position:t.position.getPolled(),duration:t.duration,playbackRate:t.playbackRate,maximumPosition:o,bufferGap:t.bufferGap===void 0||!isFinite(t.bufferGap)?0:t.bufferGap};if(i!==null&&i.isLive&&t.position.getPolled()>0){let u=(d=i.availabilityStartTime)!=null?d:0;a.wallClockTime=t.position.getPolled()+u;let c=bn(i);c!==void 0&&(a.liveGap=c-t.position.getPolled())}else if(r&&this.videoElement!==null){let u=mo(this.videoElement);u!==void 0&&(a.wallClockTime=u+t.position.getPolled())}this.trigger("positionUpdate",a)}_priv_triggerEventIfNotStopped(e,t,r){r.isCancelled()||this.trigger(e,t)}_priv_initializeMediaElementTracksStore(e){var r,i,o;ee(fe.directfile!==null,"Initializing `MediaElementTracksStore` without Directfile feature"),ee(this.videoElement!==null,"Initializing `MediaElementTracksStore` on a disposed RxPlayer");let t=new fe.directfile.mediaElementTracksStore(this.videoElement);return this._priv_triggerEventIfNotStopped("availableAudioTracksChange",t.getAvailableAudioTracks(),e),this._priv_triggerEventIfNotStopped("availableVideoTracksChange",t.getAvailableVideoTracks(),e),this._priv_triggerEventIfNotStopped("availableTextTracksChange",t.getAvailableTextTracks(),e),this._priv_triggerEventIfNotStopped("audioTrackChange",(r=t.getChosenAudioTrack())!=null?r:null,e),this._priv_triggerEventIfNotStopped("textTrackChange",(i=t.getChosenTextTrack())!=null?i:null,e),this._priv_triggerEventIfNotStopped("videoTrackChange",(o=t.getChosenVideoTrack())!=null?o:null,e),t.addEventListener("availableVideoTracksChange",a=>this.trigger("availableVideoTracksChange",a)),t.addEventListener("availableAudioTracksChange",a=>this.trigger("availableAudioTracksChange",a)),t.addEventListener("availableTextTracksChange",a=>this.trigger("availableTextTracksChange",a)),t.addEventListener("audioTrackChange",a=>this.trigger("audioTrackChange",a)),t.addEventListener("videoTrackChange",a=>this.trigger("videoTrackChange",a)),t.addEventListener("textTrackChange",a=>this.trigger("textTrackChange",a)),t}_priv_callTracksStoreGetterSetter(e,t,r){var d,u;if(this._priv_contentInfos===null||this._priv_contentInfos.tracksStore===null)return m.warn("API: Trying to call track API too soon"),t;let{tracksStore:i}=this._priv_contentInfos,o=(u=(d=this._priv_contentInfos)==null?void 0:d.currentPeriod)!=null?u:void 0,a=e!=null?e:o==null?void 0:o.id;if(a===void 0)return t;let s=a===(o==null?void 0:o.id)?i.getPeriodObjectFromPeriod(o):i.getPeriodObjectFromId(a);return s===void 0?t:r(i,s)}_priv_onAvailableTracksMayHaveChanged(e,t){let r=this._priv_contentInfos;if(r===null)return;let{currentPeriod:i,tracksStore:o,currentContentCanceller:a}=r,s=a.signal;if(_(i)||o===null)return;let d=t!=null?t:o.getPeriodObjectFromPeriod(i);if(d!==void 0)switch(e){case"video":{let u=o.getAvailableVideoTracks(d,!0);this._priv_triggerEventIfNotStopped("availableVideoTracksChange",u!=null?u:[],s);break}case"audio":{let u=o.getAvailableAudioTracks(d,!0);this._priv_triggerEventIfNotStopped("availableAudioTracksChange",u!=null?u:[],s);break}case"text":{let u=o.getAvailableTextTracks(d);this._priv_triggerEventIfNotStopped("availableTextTracksChange",u!=null?u:[],s);break}default:He(e)}}_priv_onFatalError(e,t){let r=Ee(e,{defaultCode:"NONE",defaultReason:"An unknown error stopped content playback."});r.fatal=!0,t.currentContentCanceller.cancel(),this._priv_cleanUpCurrentContentState(),this._priv_currentError=r,m.error("API: The player stopped because of an error",r),this._priv_setPlayerState("STOPPED"),this._priv_currentError===r&&this.trigger("error",r)}};Vt._priv_currentlyUsedVideoElements=new WeakSet;var za=Vt;za.version="4.3.1-dev.2025041000";var Ep=za;var Ha=Ep;Wa();Ha.addFeatures([Ul,_u,Pu,Cu,vl,bl,Cl,Tl,rl,Ou,gl,Nu]);Bn()?m.setLevel("DEBUG","full"):y.CURRENT_ENV===y.DEV&&m.setLevel(S.CURRENT_LEVEL,"standard");var use=Ha;J.RxPlayer=Ha;})();
|
|
18
|
+
Make sure to dispose the previous instance with player.dispose() before creating a new player instance attaching that video element.`),Vt._priv_currentlyUsedVideoElements.add(e)}static _priv_deregisterVideoElement(e){Vt._priv_currentlyUsedVideoElements.has(e)&&Vt._priv_currentlyUsedVideoElements.delete(e)}constructor(e={}){super();let{baseBandwidth:t,videoResolutionLimit:r,maxBufferAhead:i,maxBufferBehind:o,throttleVideoBitrateWhenHidden:a,videoElement:s,wantedBufferAhead:d,maxVideoBufferSize:u}=yp(e);s.preload="auto",this.version="4.3.1-dev.2025041002",this.log=m,this.state="STOPPED",this.videoElement=s,Vt._priv_registerVideoElement(this.videoElement);let c=new U;this._destroyCanceller=c,this._priv_pictureInPictureRef=Mc(s,c.signal),this._priv_speed=new G(s.playbackRate,this._destroyCanceller.signal),this._priv_preferTrickModeTracks=!1,this._priv_contentLock=new G(!1,this._destroyCanceller.signal),this._priv_bufferOptions={wantedBufferAhead:new G(d,this._destroyCanceller.signal),maxBufferAhead:new G(i,this._destroyCanceller.signal),maxBufferBehind:new G(o,this._destroyCanceller.signal),maxVideoBufferSize:new G(u,this._destroyCanceller.signal)},this._priv_bitrateInfos={lastBitrates:{audio:t,video:t}},this._priv_throttleVideoBitrateWhenHidden=a,this._priv_videoResolutionLimit=r,this._priv_currentError=null,this._priv_contentInfos=null,this._priv_contentEventsMemory={},this._priv_reloadingMetadata={},this._priv_lastAutoPlay=!1,this._priv_worker=null;let l=()=>{this.trigger("volumeChange",{volume:s.volume,muted:s.muted})};s.addEventListener("volumechange",l),c.signal.register(()=>{s.removeEventListener("volumechange",l)})}attachWorker(e){return new Promise((t,r)=>{var a;if(!Fl())return m.warn("API: Cannot rely on a WebWorker: Worker API unavailable"),r(new Un("INCOMPATIBLE_ERROR","Worker unavailable"));if(typeof e.workerUrl=="string")this._priv_worker=new Worker(e.workerUrl);else{let s=URL.createObjectURL(e.workerUrl);this._priv_worker=new Worker(s),URL.revokeObjectURL(s)}this._priv_worker.onerror=s=>{this._priv_worker!==null&&(this._priv_worker.terminate(),this._priv_worker=null),m.error("API: Unexpected worker error",s.error instanceof Error?s.error:void 0),r(new Un("UNKNOWN_ERROR",'Unexpected Worker "error" event'))};let i=s=>{let d=s.data;d.type==="init-error"?(m.warn("API: Processing InitError worker message: detaching worker"),this._priv_worker!==null&&(this._priv_worker.removeEventListener("message",i),this._priv_worker.terminate(),this._priv_worker=null),r(new Un("SETUP_ERROR","Worker parser initialization failed: "+d.value.errorMessage))):d.type==="init-success"&&(m.info("API: InitSuccess received from worker."),this._priv_worker!==null&&this._priv_worker.removeEventListener("message",i),t())};this._priv_worker.addEventListener("message",i),m.debug("---> Sending To Worker:","init"),this._priv_worker.postMessage({type:"init",value:{dashWasmUrl:e.dashWasmUrl,logLevel:m.getLevel(),logFormat:m.getFormat(),sendBackLogs:Bn(),date:Date.now(),timestamp:V(),hasVideo:((a=this.videoElement)==null?void 0:a.nodeName.toLowerCase())==="video"}}),m.addEventListener("onLogLevelChange",s=>{this._priv_worker!==null&&(m.debug("---> Sending To Worker:","log-level-update"),this._priv_worker.postMessage({type:"log-level-update",value:{logLevel:s.level,logFormat:s.format,sendBackLogs:Bn()}}))},this._destroyCanceller.signal);let o=s=>{this._priv_worker!==null&&(m.debug("---> Sending To Worker:","config-update"),this._priv_worker.postMessage({type:"config-update",value:s}))};L.updated&&o(L.getCurrent()),L.addEventListener("update",o,this._destroyCanceller.signal)})}getCurrentModeInformation(){return this._priv_contentInfos===null?null:{isDirectFile:this._priv_contentInfos.isDirectFile,useWorker:this._priv_contentInfos.useWorker}}addEventListener(e,t){return super.addEventListener(e,t)}stop(){this._priv_contentInfos!==null&&this._priv_contentInfos.currentContentCanceller.cancel(),this._priv_cleanUpCurrentContentState(),this.state!=="STOPPED"&&this._priv_setPlayerState("STOPPED")}dispose(){this.stop(),this.videoElement!==null&&(Vt._priv_deregisterVideoElement(this.videoElement),zn(this.videoElement).catch(e=>{let t=e instanceof Error?e.message:"Unknown error";m.error("API: Could not dispose decryption resources: "+t)})),this._destroyCanceller.cancel(),this._priv_reloadingMetadata={},this.videoElement=null,this._priv_worker!==null&&(this._priv_worker.terminate(),this._priv_worker=null)}loadVideo(e){let t=bp(e);m.info("API: Calling loadvideo",t.url,t.transport),this._priv_reloadingMetadata={options:t},this._priv_initializeContentPlayback(t),this._priv_lastAutoPlay=t.autoPlay}reload(e){var c,l,f;let{options:t,manifest:r,reloadPosition:i,reloadInPause:o}=this._priv_reloadingMetadata;if(t===void 0)throw new Error("API: Can't reload without having previously loaded a content.");Ip(e);let a;if(((c=e==null?void 0:e.reloadAt)==null?void 0:c.position)!==void 0)a={position:e.reloadAt.position};else if(((l=e==null?void 0:e.reloadAt)==null?void 0:l.relative)!==void 0){if(i===void 0)throw new Error("Can't reload to a relative position when previous content was not loaded.");a={position:e.reloadAt.relative+i}}else i!==void 0&&(a={position:i});let s;(e==null?void 0:e.autoPlay)!==void 0?s=e.autoPlay:o!==void 0&&(s=!o);let d;(e==null?void 0:e.keySystems)!==void 0?d=e.keySystems:((f=this._priv_reloadingMetadata.options)==null?void 0:f.keySystems)!==void 0&&(d=this._priv_reloadingMetadata.options.keySystems);let u=de(oe({},t),{initialManifest:r});a!==void 0&&(u.startAt=a),s!==void 0&&(u.autoPlay=s),d!==void 0&&(u.keySystems=d),this._priv_initializeContentPlayback(u)}createDebugElement(e){if(fe.createDebugElement===null)throw new Error("Feature `DEBUG_ELEMENT` not added to the RxPlayer");let t=new U;return fe.createDebugElement(e,this,t.signal),{dispose(){t.cancel()}}}getAvailableThumbnailTracks({time:e,periodId:t}={}){if(this._priv_contentInfos===null||this._priv_contentInfos.manifest===null)return[];let{manifest:r}=this._priv_contentInfos,i;if(e!==void 0){if(i=Vn(this._priv_contentInfos.manifest,e),i===void 0||i.thumbnailTracks.length===0)return[]}else if(t!==void 0){if(i=Q(r.periods,o=>o.id===t),i===void 0)return m.error("API: getAvailableThumbnailTracks: periodId not found"),[]}else{let{currentPeriod:o}=this._priv_contentInfos;if(o===null)return[];i=o}return i.thumbnailTracks.map(o=>({id:o.id,width:Math.floor(o.width/o.horizontalTiles),height:Math.floor(o.height/o.verticalTiles),mimeType:o.mimeType}))}async renderThumbnail(e){if(_(e.time))throw new Error("You have to provide a `time` property to `renderThumbnail`, indicating the wanted thumbnail time in seconds.");if(_(e.container))throw new Error("You have to provide a `container` property to `renderThumbnail`, specifying the HTML Element in which the thumbnail should be inserted.");return Kl(this._priv_contentInfos,e)}_priv_initializeContentPlayback(e){var q,ie,ne,le,be,me;let{autoPlay:t,cmcd:r,defaultAudioTrackSwitchingMode:i,enableFastSwitching:o,initialManifest:a,keySystems:s,lowLatencyMode:d,minimumManifestUpdateInterval:u,requestConfig:c,onCodecSwitch:l,startAt:f,transport:p,checkMediaSegmentIntegrity:g,checkManifestIntegrity:b,manifestLoader:h,referenceDateTime:I,segmentLoader:T,serverSyncInfos:R,mode:E,experimentalOptions:v,__priv_manifestUpdateUrl:k,__priv_patchLastSegmentInSidx:x,url:P}=e;if(this.videoElement===null)throw new Error("the attached video element is disposed");let M=p==="directfile",O=new U,B=this.videoElement,D,F=!1,A=null;if(M){if(fe.directfile===null)throw this.stop(),this._priv_currentError=null,new Error("DirectFile feature not activated in your build.");if(_(P))throw new Error("No URL for a DirectFile content");if(m.info("API: Initializing DirectFile mode in the main thread"),A=this._priv_initializeMediaElementTracksStore(O.signal),O.isUsed())return;D=new fe.directfile.initDirectFile({autoPlay:t,keySystems:s,speed:this._priv_speed,startAt:f,url:P})}else{let W={lowLatencyMode:d,maxRetry:(q=c.manifest)==null?void 0:q.maxRetry,requestTimeout:(ie=c.manifest)==null?void 0:ie.timeout,connectionTimeout:(ne=c.manifest)==null?void 0:ne.connectionTimeout,minimumManifestUpdateInterval:u,initialManifest:a},Ce=Bl(),nt={throttleBitrate:{},limitResolution:{}};this._priv_throttleVideoBitrateWhenHidden&&(Ce?nt.throttleBitrate={video:cn(Ac(this._priv_pictureInPictureRef,O.signal),Ht=>Ht?1/0:0,O.signal)}:m.warn("API: Can't apply throttleVideoBitrateWhenHidden because browser can't be trusted for visibility.")),this._priv_videoResolutionLimit==="videoElement"?Ce?nt.limitResolution={video:wc(B,this._priv_pictureInPictureRef,O.signal)}:m.warn("API: Can't apply videoResolutionLimit because browser can't be trusted for video size."):this._priv_videoResolutionLimit==="screen"&&(nt.limitResolution={video:xc(O.signal)});let Ae={initialBitrates:this._priv_bitrateInfos.lastBitrates,lowLatencyMode:d,throttlers:nt},zt=e.textTrackMode==="native"?{textTrackMode:"native"}:{textTrackMode:"html",textTrackElement:e.textTrackElement},ln=Y({enableFastSwitching:o,onCodecSwitch:l},this._priv_bufferOptions),mt={lowLatencyMode:d,maxRetry:(le=c.segment)==null?void 0:le.maxRetry,requestTimeout:(be=c.segment)==null?void 0:be.timeout,connectionTimeout:(me=c.segment)==null?void 0:me.connectionTimeout},St=fe.multithread!==null&&this._priv_worker!==null&&p==="dash"&&Vb.every(Ht=>_(e[Ht]))&&typeof e.representationFilter!="function";if(E==="main"||E==="auto"&&!St){if(fe.mainThreadMediaSourceInit===null)throw new Error("Cannot load video, neither in a WebWorker nor with the `MEDIA_SOURCE_MAIN` feature");let Ht=fe.transports[p];if(typeof Ht!="function")throw this.stop(),this._priv_currentError=null,new Error(`transport "${p}" not supported`);let vp=typeof e.representationFilter=="string"?kc(e.representationFilter):e.representationFilter;m.info("API: Initializing MediaSource mode in the main thread");let Rp=Ht({lowLatencyMode:d,checkMediaSegmentIntegrity:g,checkManifestIntegrity:b,manifestLoader:h,referenceDateTime:I,representationFilter:vp,segmentLoader:T,serverSyncInfos:R,__priv_manifestUpdateUrl:k,__priv_patchLastSegmentInSidx:x});D=new fe.mainThreadMediaSourceInit({adaptiveOptions:Ae,autoPlay:t,bufferOptions:ln,cmcd:r,enableRepresentationAvoidance:v.enableRepresentationAvoidance,keySystems:s,lowLatencyMode:d,transport:Rp,manifestRequestSettings:W,segmentRequestOptions:mt,speed:this._priv_speed,startAt:f,textTrackOptions:zt,url:P})}else{if(fe.multithread===null)throw new Error("Cannot load video in multithread mode: `MULTI_THREAD` feature not imported.");if(this._priv_worker===null)throw new Error("Cannot load video in multithread mode: `attachWorker` method not called.");ee(typeof e.representationFilter!="function"),F=!0,m.info("API: Initializing MediaSource mode in a WebWorker");let Ht={lowLatencyMode:d,checkMediaSegmentIntegrity:g,checkManifestIntegrity:b,referenceDateTime:I,serverSyncInfos:R,manifestLoader:void 0,segmentLoader:void 0,representationFilter:e.representationFilter,__priv_manifestUpdateUrl:k,__priv_patchLastSegmentInSidx:x};D=new fe.multithread.init({adaptiveOptions:Ae,autoPlay:t,bufferOptions:ln,cmcd:r,enableRepresentationAvoidance:v.enableRepresentationAvoidance,keySystems:s,lowLatencyMode:d,transportOptions:Ht,manifestRequestSettings:W,segmentRequestOptions:mt,speed:this._priv_speed,startAt:f,textTrackOptions:zt,worker:this._priv_worker,url:P,useMseInWorker:cm})}}let C={contentId:Kb(),originalUrl:P,currentContentCanceller:O,defaultAudioTrackSwitchingMode:i,initializer:D,isDirectFile:M,manifest:null,currentPeriod:null,activeAdaptations:null,activeRepresentations:null,tracksStore:null,mediaElementTracksStore:A,useWorker:F,segmentSinkMetricsCallback:null,fetchThumbnailDataCallback:null,thumbnailRequestsInfo:{pendingRequests:new WeakMap,lastResponse:null}};D.addEventListener("error",W=>{this._priv_onFatalError(W,C)}),D.addEventListener("warning",W=>{let Ce=Ee(W,{defaultCode:"NONE",defaultReason:"An unknown error happened."});m.warn("API: Sending warning:",Ce),this.trigger("warning",Ce)}),D.addEventListener("reloadingMediaSource",W=>{C.tracksStore!==null&&C.tracksStore.resetPeriodObjects(),this._priv_contentInfos!==null&&(this._priv_contentInfos.segmentSinkMetricsCallback=null),this._priv_lastAutoPlay=W.autoPlay}),D.addEventListener("inbandEvents",W=>this.trigger("inbandEvents",W)),D.addEventListener("streamEvent",W=>this.trigger("streamEvent",W)),D.addEventListener("streamEventSkip",W=>this.trigger("streamEventSkip",W)),D.addEventListener("activePeriodChanged",W=>this._priv_onActivePeriodChanged(C,W)),D.addEventListener("periodStreamReady",W=>this._priv_onPeriodStreamReady(C,W)),D.addEventListener("periodStreamCleared",W=>this._priv_onPeriodStreamCleared(C,W)),D.addEventListener("representationChange",W=>this._priv_onRepresentationChange(C,W)),D.addEventListener("adaptationChange",W=>this._priv_onAdaptationChange(C,W)),D.addEventListener("bitrateEstimateChange",W=>this._priv_onBitrateEstimateChange(W)),D.addEventListener("manifestReady",W=>this._priv_onManifestReady(C,W)),D.addEventListener("manifestUpdate",W=>this._priv_onManifestUpdate(C,W)),D.addEventListener("codecSupportUpdate",()=>this._priv_onCodecSupportUpdate(C)),D.addEventListener("decipherabilityUpdate",W=>this._priv_onDecipherabilityUpdate(C,W)),D.addEventListener("loaded",W=>{this._priv_contentInfos!==null&&(this._priv_contentInfos.segmentSinkMetricsCallback=W.getSegmentSinkMetrics,this._priv_contentInfos.fetchThumbnailDataCallback=W.getThumbnailData)}),D.prepare(),this.stop();let N=new po(B,{withMediaSource:!M,lowLatencyMode:d});O.signal.register(()=>{N.stop()});let K=_p(D,B,N,O.signal);O.signal.register(()=>{D.dispose()});let j=W=>{switch(W){case"STOPPED":case"RELOADING":case"LOADING":break;case"ENDED":this._priv_reloadingMetadata.reloadInPause=!0,this._priv_reloadingMetadata.reloadPosition=N.getReference().getValue().position.getPolled();break;default:{let Ce=N.getReference().getValue();this._priv_reloadingMetadata.reloadInPause=Ce.paused,this._priv_reloadingMetadata.reloadPosition=Ce.position.getWanted();break}}},$=null,z=W=>{$!==null&&($.cancel(),$=null),K.onUpdate((Ce,nt)=>{mr(Ce)&&(nt(),$!==null&&$.cancel(),$=new U,$.linkToSignal(O.signal),W!==!B.paused&&(B.paused?this.trigger("pause",null):this.trigger("play",null)),Tp(B,()=>this.trigger("play",null),()=>this.trigger("pause",null),O.signal))},{emitCurrentValue:!1,clearSignal:O.signal})};z(t),D.addEventListener("reloadingMediaSource",W=>{z(W.autoPlay)}),this._priv_currentError=null,this._priv_contentInfos=C;let H=null;K.onUpdate(W=>{j(W),this._priv_setPlayerState(W),!O.isUsed()&&(H!==null?mr(this.state)||(H.cancel(),H=null):mr(this.state)&&(H=new U,H.linkToSignal(O.signal),Sp(N,()=>this.trigger("seeking",null),()=>this.trigger("seeked",null),H.signal)))},{emitCurrentValue:!0,clearSignal:O.signal}),N.listen(W=>{j(this.state),this._priv_triggerPositionUpdate(C,W)},{clearSignal:O.signal}),O.signal.register(()=>{D.removeEventListener()}),this._priv_contentLock.onUpdate((W,Ce)=>{W||(Ce(),D.start(B,N))},{emitCurrentValue:!0,clearSignal:O.signal})}getError(){return this._priv_currentError}getVideoElement(){return this.videoElement}getPlayerState(){return this.state}isContentLoaded(){return!X(["LOADING","RELOADING","STOPPED"],this.state)}isBuffering(){return X(["BUFFERING","SEEKING","LOADING","RELOADING"],this.state)}isPaused(){return this.videoElement!==null?X(["LOADING","RELOADING"],this.state)?!this._priv_lastAutoPlay:this.videoElement.paused:!0}isLive(){if(this._priv_contentInfos===null)return!1;let{isDirectFile:e,manifest:t}=this._priv_contentInfos;return e||t===null?!1:t.isLive}areTrickModeTracksEnabled(){return this._priv_preferTrickModeTracks}getContentUrls(){if(this._priv_contentInfos===null)return;let{isDirectFile:e,manifest:t,originalUrl:r}=this._priv_contentInfos;if(e)return r===void 0?void 0:[r];if(t!==null)return t.uris}updateContentUrls(e,t){if(this._priv_contentInfos===null)throw new Error("No content loaded");let r=(t==null?void 0:t.refresh)===!0;this._priv_contentInfos.initializer.updateContentUrls(e,r)}getMediaDuration(){if(this.videoElement===null)throw new Error("Disposed player");return this.videoElement.duration}getCurrentBufferGap(){if(this.videoElement===null)throw new Error("Disposed player");let e=this.videoElement,t=uc(e.buffered,e.currentTime);return t===1/0?0:t}getWallClockTime(){var r;if(this.videoElement===null)throw new Error("Disposed player");if(this._priv_contentInfos===null)return this.videoElement.currentTime;let{isDirectFile:e,manifest:t}=this._priv_contentInfos;if(e){let i=mo(this.videoElement);return(i!=null?i:0)+this.videoElement.currentTime}if(t!==null){let i=this.videoElement.currentTime,o=(r=t.availabilityStartTime)!=null?r:0;return i+o}return 0}getPosition(){if(this.videoElement===null)throw new Error("Disposed player");return this.videoElement.currentTime}getLastStoredContentPosition(){return this._priv_reloadingMetadata.reloadPosition}getPlaybackRate(){return this._priv_speed.getValue()}setPlaybackRate(e,t){var o;e!==this._priv_speed.getValue()&&this._priv_speed.setValue(e);let r=t==null?void 0:t.preferTrickModeTracks;if(typeof r!="boolean")return;this._priv_preferTrickModeTracks=r;let i=(o=this._priv_contentInfos)==null?void 0:o.tracksStore;_(i)||(r&&!i.isTrickModeEnabled()?i.enableVideoTrickModeTracks():!r&&i.isTrickModeEnabled()&&i.disableVideoTrickModeTracks())}getVideoRepresentation(){let e=this.__priv_getCurrentRepresentations();if(e!==null)return e.video}getAudioRepresentation(){let e=this.__priv_getCurrentRepresentations();if(e!==null)return e.audio}play(){if(this.videoElement===null)throw new Error("Disposed player");let e=this.videoElement.play();return _(e)||typeof e.catch!="function"?Promise.resolve():e.catch(t=>{if(t.name==="NotAllowedError"){let r=new te("MEDIA_ERR_PLAY_NOT_ALLOWED",t.toString());this.trigger("warning",r)}throw t})}pause(){if(this.videoElement===null)throw new Error("Disposed player");this.videoElement.pause()}seekTo(e){var o;if(this.videoElement===null)throw new Error("Disposed player");if(this._priv_contentInfos===null)throw new Error("player: no content loaded");let{isDirectFile:t,manifest:r}=this._priv_contentInfos;if(!t&&r===null)throw new Error("player: the content did not load yet");let i;if(typeof e=="number")i=e;else if(typeof e=="object"){let a=e,s=this.videoElement.currentTime;if(!_(a.relative))i=s+a.relative;else if(!_(a.position))i=a.position;else{if(_(a.wallClockTime))throw new Error('invalid time object. You must set one of the following properties: "relative", "position" or "wallClockTime"');if(r!==null)i=a.wallClockTime-((o=r.availabilityStartTime)!=null?o:0);else if(t&&this.videoElement!==null){let d=mo(this.videoElement);d!==void 0&&(i=a.wallClockTime-d)}i===void 0&&(i=a.wallClockTime)}}if(i===void 0)throw new Error("invalid time given");return m.info("API: API Seek to",i),this.videoElement.currentTime=i,i}getVolume(){if(this.videoElement===null)throw new Error("Disposed player");return this.videoElement.volume}setVolume(e){if(this.videoElement===null)throw new Error("Disposed player");let t=this.videoElement;e!==t.volume&&(t.volume=e)}isMute(){var e;return((e=this.videoElement)==null?void 0:e.muted)===!0}mute(){if(this.videoElement===null)throw new Error("Disposed player");this.videoElement.muted||(this.videoElement.muted=!0)}unMute(){if(this.videoElement===null)throw new Error("Disposed player");this.videoElement.muted&&(this.videoElement.muted=!1)}setMaxBufferBehind(e){this._priv_bufferOptions.maxBufferBehind.setValue(e)}setMaxBufferAhead(e){this._priv_bufferOptions.maxBufferAhead.setValue(e)}setWantedBufferAhead(e){this._priv_bufferOptions.wantedBufferAhead.setValue(e)}setMaxVideoBufferSize(e){this._priv_bufferOptions.maxVideoBufferSize.setValue(e)}getMaxBufferBehind(){return this._priv_bufferOptions.maxBufferBehind.getValue()}getMaxBufferAhead(){return this._priv_bufferOptions.maxBufferAhead.getValue()}getWantedBufferAhead(){return this._priv_bufferOptions.wantedBufferAhead.getValue()}getMaxVideoBufferSize(){return this._priv_bufferOptions.maxVideoBufferSize.getValue()}getCurrentPeriod(){var t;let e=(t=this._priv_contentInfos)==null?void 0:t.currentPeriod;return _(e)?null:{id:e.id,start:e.start,end:e.end}}getKeySystemConfiguration(){if(this.videoElement===null)throw new Error("Disposed player");let e=$n(this.videoElement);return e===null?null:{keySystem:e[0],configuration:e[1]}}getAvailablePeriods(){if(this._priv_contentInfos===null)return[];let{isDirectFile:e,tracksStore:t}=this._priv_contentInfos;return e?[]:t===null?[]:t.getAvailablePeriods().slice()}getAvailableAudioTracks(e){var a,s;if(this._priv_contentInfos===null)return[];let{isDirectFile:t,mediaElementTracksStore:r}=this._priv_contentInfos;if(t)return(a=r==null?void 0:r.getAvailableAudioTracks())!=null?a:[];let i,o=!0;return typeof e=="string"?i=e:(i=e==null?void 0:e.periodId,o=(s=e==null?void 0:e.filterPlayableRepresentations)!=null?s:!0),this._priv_callTracksStoreGetterSetter(i,[],(d,u)=>{var c;return(c=d.getAvailableAudioTracks(u,o))!=null?c:[]})}getAvailableTextTracks(e){var i;if(this._priv_contentInfos===null)return[];let{isDirectFile:t,mediaElementTracksStore:r}=this._priv_contentInfos;return t?(i=r==null?void 0:r.getAvailableTextTracks())!=null?i:[]:this._priv_callTracksStoreGetterSetter(e,[],(o,a)=>{var s;return(s=o.getAvailableTextTracks(a))!=null?s:[]})}getAvailableVideoTracks(e){var a,s;if(this._priv_contentInfos===null)return[];let{isDirectFile:t,mediaElementTracksStore:r}=this._priv_contentInfos;if(t)return(a=r==null?void 0:r.getAvailableVideoTracks())!=null?a:[];let i,o=!0;return typeof e=="string"?i=e:(i=e==null?void 0:e.periodId,o=(s=e==null?void 0:e.filterPlayableRepresentations)!=null?s:!0),this._priv_callTracksStoreGetterSetter(i,[],(d,u)=>{var c;return(c=d.getAvailableVideoTracks(u,o))!=null?c:[]})}getAudioTrack(e){var a;if(this._priv_contentInfos===null)return;let{isDirectFile:t,mediaElementTracksStore:r}=this._priv_contentInfos;if(t)return r===null?void 0:r.getChosenAudioTrack();let i,o=!0;return typeof e=="string"?i=e:(i=e==null?void 0:e.periodId,o=(a=e==null?void 0:e.filterPlayableRepresentations)!=null?a:!0),this._priv_callTracksStoreGetterSetter(i,void 0,(s,d)=>s.getChosenAudioTrack(d,o))}getTextTrack(e){if(this._priv_contentInfos===null)return;let{isDirectFile:t,mediaElementTracksStore:r}=this._priv_contentInfos;return t?r===null?void 0:r.getChosenTextTrack():this._priv_callTracksStoreGetterSetter(e,void 0,(i,o)=>i.getChosenTextTrack(o))}getVideoTrack(e){var a;if(this._priv_contentInfos===null)return;let{isDirectFile:t,mediaElementTracksStore:r}=this._priv_contentInfos;if(t)return r===null?void 0:r.getChosenVideoTrack();let i,o=!0;return typeof e=="string"?i=e:(i=e==null?void 0:e.periodId,o=(a=e==null?void 0:e.filterPlayableRepresentations)!=null?a:!0),this._priv_callTracksStoreGetterSetter(i,void 0,(s,d)=>s.getChosenVideoTrack(d,o))}setAudioTrack(e){var u;if(this._priv_contentInfos===null)throw new Error("No content loaded");let{isDirectFile:t,mediaElementTracksStore:r}=this._priv_contentInfos;if(t)try{let c=typeof e=="string"?e:e.trackId;r==null||r.setAudioTrackById(c);return}catch(c){throw new Error("player: unknown audio track")}let i,o,a,s=null,d;return typeof e=="string"?o=e:(o=e.trackId,i=e.periodId,a=e.switchingMode,s=(u=e.lockedRepresentations)!=null?u:null,d=e.relativeResumingPosition),this._priv_callTracksStoreGetterSetter(i,void 0,(c,l)=>c.setAudioTrack({periodRef:l,trackId:o,switchingMode:a,lockedRepresentations:s,relativeResumingPosition:d}))}setTextTrack(e){if(this._priv_contentInfos===null)throw new Error("No content loaded");let{isDirectFile:t,mediaElementTracksStore:r}=this._priv_contentInfos;if(t)try{let a=typeof e=="string"?e:e.trackId;r==null||r.setTextTrackById(a);return}catch(a){throw new Error("player: unknown text track")}let i,o;return typeof e=="string"?o=e:(o=e.trackId,i=e.periodId),this._priv_callTracksStoreGetterSetter(i,void 0,(a,s)=>a.setTextTrack(s,o))}disableTextTrack(e){if(this._priv_contentInfos===null)return;let{isDirectFile:t,mediaElementTracksStore:r}=this._priv_contentInfos;if(t){r==null||r.disableTextTrack();return}return this._priv_callTracksStoreGetterSetter(e,void 0,(i,o)=>i.disableTrack(o,"text"))}setVideoTrack(e){var u;if(this._priv_contentInfos===null)throw new Error("No content loaded");let{isDirectFile:t,mediaElementTracksStore:r}=this._priv_contentInfos;if(t)try{let c=typeof e=="string"?e:e.trackId;r==null||r.setVideoTrackById(c);return}catch(c){throw new Error("player: unknown video track")}let i,o,a,s=null,d;return typeof e=="string"?o=e:(o=e.trackId,i=e.periodId,a=e.switchingMode,s=(u=e.lockedRepresentations)!=null?u:null,d=e.relativeResumingPosition),this._priv_callTracksStoreGetterSetter(i,void 0,(c,l)=>c.setVideoTrack({periodRef:l,trackId:o,switchingMode:a,lockedRepresentations:s,relativeResumingPosition:d}))}disableVideoTrack(e){if(this._priv_contentInfos===null)return;let{isDirectFile:t,mediaElementTracksStore:r}=this._priv_contentInfos;return t&&r!==null?r.disableVideoTrack():this._priv_callTracksStoreGetterSetter(e,void 0,(i,o)=>i.disableTrack(o,"video"))}lockVideoRepresentations(e){if(this._priv_contentInfos===null)throw new Error("No content loaded");let{isDirectFile:t}=this._priv_contentInfos;if(t)throw new Error("Cannot lock video Representations in directfile mode.");let r,i,o;return Array.isArray(e)?(r=e,i=void 0):(r=e.representations,i=e.periodId,o=e.switchingMode),this._priv_callTracksStoreGetterSetter(i,void 0,(a,s)=>a.lockVideoRepresentations(s,{representations:r,switchingMode:o}))}lockAudioRepresentations(e){if(this._priv_contentInfos===null)throw new Error("No content loaded");let{isDirectFile:t}=this._priv_contentInfos;if(t)throw new Error("Cannot lock audio Representations in directfile mode.");let r,i,o;return Array.isArray(e)?(r=e,i=void 0):(r=e.representations,i=e.periodId,o=e.switchingMode),this._priv_callTracksStoreGetterSetter(i,void 0,(a,s)=>a.lockAudioRepresentations(s,{representations:r,switchingMode:o}))}getLockedVideoRepresentations(e){if(this._priv_contentInfos===null)return null;let{isDirectFile:t}=this._priv_contentInfos;return t?null:this._priv_callTracksStoreGetterSetter(e,null,(r,i)=>r.getLockedVideoRepresentations(i))}getLockedAudioRepresentations(e){if(this._priv_contentInfos===null)return null;let{isDirectFile:t}=this._priv_contentInfos;return t?null:this._priv_callTracksStoreGetterSetter(e,null,(r,i)=>r.getLockedAudioRepresentations(i))}unlockVideoRepresentations(e){if(this._priv_contentInfos===null)return;let{isDirectFile:t}=this._priv_contentInfos;if(!t)return this._priv_callTracksStoreGetterSetter(e,void 0,(r,i)=>r.unlockVideoRepresentations(i))}unlockAudioRepresentations(e){if(this._priv_contentInfos===null)return;let{isDirectFile:t}=this._priv_contentInfos;if(!t)return this._priv_callTracksStoreGetterSetter(e,void 0,(r,i)=>r.unlockAudioRepresentations(i))}getMinimumPosition(){if(this._priv_contentInfos===null)return null;if(this._priv_contentInfos.isDirectFile)return 0;let{manifest:e}=this._priv_contentInfos;return e!==null?In(e):null}getLivePosition(){if(this._priv_contentInfos===null)return null;let{isDirectFile:e,manifest:t}=this._priv_contentInfos;if(!e)return(t==null?void 0:t.isLive)!==!0?null:bn(t)}getMaximumPosition(){if(this._priv_contentInfos===null)return null;let{isDirectFile:e,manifest:t}=this._priv_contentInfos;if(e){if(this.videoElement===null)throw new Error("Disposed player");return this.videoElement.duration}return t!==null?!t.isDynamic&&this.videoElement!==null?this.videoElement.duration:_t(t):null}async __priv_getSegmentSinkMetrics(){var e,t;return(t=(e=this._priv_contentInfos)==null?void 0:e.segmentSinkMetricsCallback)==null?void 0:t.call(e)}__priv_getManifest(){return this._priv_contentInfos===null?null:this._priv_contentInfos.manifest}__priv_getCurrentAdaptation(){if(this._priv_contentInfos===null)return null;let{currentPeriod:e,activeAdaptations:t}=this._priv_contentInfos;return e===null||t===null||_(t[e.id])?null:t[e.id]}__priv_getCurrentRepresentations(){if(this._priv_contentInfos===null)return null;let{currentPeriod:e,activeRepresentations:t}=this._priv_contentInfos;return e===null||t===null||_(t[e.id])?null:t[e.id]}_priv_cleanUpCurrentContentState(){var t,r,i,o;m.debug("Locking `contentLock` to clean-up the current content."),this._priv_contentLock.setValue(!0),(r=(t=this._priv_contentInfos)==null?void 0:t.tracksStore)==null||r.dispose(),(o=(i=this._priv_contentInfos)==null?void 0:i.mediaElementTracksStore)==null||o.dispose(),this._priv_contentInfos=null,this._priv_contentEventsMemory={};let e=()=>{this.videoElement!==null&&(m.debug("Unlocking `contentLock`. Next content can begin."),this._priv_contentLock.setValue(!1))};_(this.videoElement)?e():wo(this.videoElement).then(()=>{m.debug("API: DRM session cleaned-up with success!"),e()},a=>{m.error("API: An error arised when trying to clean-up the DRM session:"+(a instanceof Error?a.toString():"Unknown Error")),e()})}_priv_onManifestReady(e,t){var i;if(e.contentId!==((i=this._priv_contentInfos)==null?void 0:i.contentId))return;e.manifest=t,t.manifestFormat===0&&(this._priv_reloadingMetadata.manifest=t);let r=new hp({preferTrickModeTracks:this._priv_preferTrickModeTracks,defaultAudioTrackSwitchingMode:e.defaultAudioTrackSwitchingMode});e.tracksStore=r,r.addEventListener("newAvailablePeriods",o=>{this.trigger("newAvailablePeriods",o)}),r.addEventListener("brokenRepresentationsLock",o=>{this.trigger("brokenRepresentationsLock",o)}),r.addEventListener("trackUpdate",o=>{var s,d;this.trigger("trackUpdate",o);let a=(d=(s=this._priv_contentInfos)==null?void 0:s.currentPeriod)!=null?d:void 0;o.reason==="no-playable-representation"&&o.period.id===(a==null?void 0:a.id)&&this._priv_onAvailableTracksMayHaveChanged(o.trackType)}),e.tracksStore.addEventListener("warning",o=>{this.trigger("warning",o)}),e.tracksStore.addEventListener("error",o=>{this._priv_onFatalError(o,e)}),e.tracksStore.onManifestUpdate(t)}_priv_onManifestUpdate(e,t){var o,a,s;if(this._priv_contentInfos===null||this._priv_contentInfos.manifest===null)return;_(e==null?void 0:e.tracksStore)||e.tracksStore.onManifestUpdate(this._priv_contentInfos.manifest);let r=(a=(o=this._priv_contentInfos)==null?void 0:o.currentPeriod)!=null?a:void 0,i=(s=this._priv_contentInfos)==null?void 0:s.tracksStore;if(!(r===void 0||_(i))){for(let d of t.updatedPeriods)if(d.period.id===r.id&&(d.result.addedAdaptations.length>0||d.result.removedAdaptations.length>0)){if(i.getPeriodObjectFromPeriod(r)===void 0)return;this._priv_onAvailableTracksMayHaveChanged("audio"),this._priv_onAvailableTracksMayHaveChanged("text"),this._priv_onAvailableTracksMayHaveChanged("video")}}}_priv_onCodecSupportUpdate(e){let t=e==null?void 0:e.tracksStore;_(t)||t.onManifestCodecSupportUpdate()}_priv_onDecipherabilityUpdate(e,t){if(e===null||e.manifest===null)return;_(e==null?void 0:e.tracksStore)||e.tracksStore.onDecipherabilityUpdates();let r=t.reduce((i,o)=>{var s,d,u;if(!(Q(i,c=>c[0].id===o.period.id&&c[1]===o.adaptation.type)!==void 0)){let c=e.tracksStore;if(c===null)return i;let l=!1,f=c.getPeriodObjectFromPeriod(o.period);if(f===void 0)return i;switch(o.adaptation.type){case"audio":l=((s=c.getChosenAudioTrack(f,!1))==null?void 0:s.id)===o.adaptation.id;break;case"video":l=((d=c.getChosenVideoTrack(f,!1))==null?void 0:d.id)===o.adaptation.id;break;case"text":l=((u=c.getChosenTextTrack(f))==null?void 0:u.id)===o.adaptation.id;break}l&&i.push([o.period,o.adaptation.type])}return i},[]);for(let[i,o]of r)this._priv_triggerEventIfNotStopped("representationListUpdate",{period:{start:i.start,end:i.end,id:i.id},trackType:o,reason:"decipherability-update"},e.currentContentCanceller.signal)}_priv_onActivePeriodChanged(e,{period:t}){var s,d,u,c,l,f;if(e.contentId!==((s=this._priv_contentInfos)==null?void 0:s.contentId))return;e.currentPeriod=t;let r=e.currentContentCanceller.signal;this._priv_contentEventsMemory.periodChange!==t&&(this._priv_contentEventsMemory.periodChange=t,this._priv_triggerEventIfNotStopped("periodChange",{start:t.start,end:t.end,id:t.id},r)),this._priv_triggerEventIfNotStopped("availableAudioTracksChange",this.getAvailableAudioTracks(),r),this._priv_triggerEventIfNotStopped("availableTextTracksChange",this.getAvailableTextTracks(),r),this._priv_triggerEventIfNotStopped("availableVideoTracksChange",this.getAvailableVideoTracks(),r);let i=(d=this._priv_contentInfos)==null?void 0:d.tracksStore;if(_(i))this._priv_triggerEventIfNotStopped("audioTrackChange",null,r),this._priv_triggerEventIfNotStopped("textTrackChange",null,r),this._priv_triggerEventIfNotStopped("videoTrackChange",null,r);else{let p=i.getPeriodObjectFromPeriod(t);if(p!==void 0){let g=i.getChosenAudioTrack(p,!0);this._priv_triggerEventIfNotStopped("audioTrackChange",g,r);let b=i.getChosenTextTrack(p);this._priv_triggerEventIfNotStopped("textTrackChange",b,r);let h=i.getChosenVideoTrack(p,!0);this._priv_triggerEventIfNotStopped("videoTrackChange",h,r)}}let o=(c=(u=this.__priv_getCurrentRepresentations())==null?void 0:u.audio)!=null?c:null;this._priv_triggerEventIfNotStopped("audioRepresentationChange",o,r);let a=(f=(l=this.__priv_getCurrentRepresentations())==null?void 0:l.video)!=null?f:null;this._priv_triggerEventIfNotStopped("videoRepresentationChange",a,r)}_priv_onPeriodStreamReady(e,t){var s;if(e.contentId!==((s=this._priv_contentInfos)==null?void 0:s.contentId))return;let{type:r,period:i,adaptationRef:o}=t,a=e.tracksStore;switch(r){case"video":case"audio":case"text":_(a)?(m.error(`API: TracksStore not instanciated for a new ${r} period`),o.setValue(null)):a.addTrackReference(r,i,o);break;default:He(r)}}_priv_onPeriodStreamCleared(e,t){var d;if(e.contentId!==((d=this._priv_contentInfos)==null?void 0:d.contentId))return;let{type:r,periodId:i}=t,o=e.tracksStore;switch(r){case"audio":case"text":case"video":_(o)||o.removeTrackReference(r,i);break}let{activeAdaptations:a,activeRepresentations:s}=e;if(!_(a)&&!_(a[i])){let u=a[i];delete u[r],Object.keys(u).length===0&&delete a[i]}if(!_(s)&&!_(s[i])){let u=s[i];delete u[r],Object.keys(u).length===0&&delete s[i]}}_priv_onAdaptationChange(e,{type:t,adaptation:r,period:i}){var c;if(e.contentId!==((c=this._priv_contentInfos)==null?void 0:c.contentId))return;e.activeAdaptations===null&&(e.activeAdaptations={});let{activeAdaptations:o,currentPeriod:a}=e,s=o[i.id];_(s)?o[i.id]={[t]:r}:s[t]=r;let{tracksStore:d}=e,u=e.currentContentCanceller.signal;if(d!==null&&a!==null&&!_(i)&&i.id===a.id){let l=d.getPeriodObjectFromPeriod(i);if(l===void 0)return;switch(t){case"audio":{let f=d.getChosenAudioTrack(l,!0);this._priv_triggerEventIfNotStopped("audioTrackChange",f,u);break}case"text":{let f=d.getChosenTextTrack(l);this._priv_triggerEventIfNotStopped("textTrackChange",f,u);break}case"video":{let f=d.getChosenVideoTrack(l,!0);this._priv_triggerEventIfNotStopped("videoTrackChange",f,u);break}}}}_priv_onRepresentationChange(e,{type:t,period:r,representation:i}){var d;if(e.contentId!==((d=this._priv_contentInfos)==null?void 0:d.contentId))return;e.activeRepresentations===null&&(e.activeRepresentations={});let{activeRepresentations:o,currentPeriod:a}=e,s=o[r.id];if(_(s)?o[r.id]={[t]:i}:s[t]=i,!_(r)&&a!==null&&a.id===r.id){let u=this._priv_contentInfos.currentContentCanceller.signal;t==="video"?this._priv_triggerEventIfNotStopped("videoRepresentationChange",i,u):t==="audio"&&this._priv_triggerEventIfNotStopped("audioRepresentationChange",i,u)}}_priv_onBitrateEstimateChange({type:e,bitrate:t}){t!==void 0&&(this._priv_bitrateInfos.lastBitrates[e]=t),this.trigger("__priv_bitrateEstimateChange",{type:e,bitrate:t})}_priv_setPlayerState(e){this.state!==e&&(this.state=e,m.info("API: playerStateChange event",e),this.trigger("playerStateChange",e))}_priv_triggerPositionUpdate(e,t){var s,d;if(e.contentId!==((s=this._priv_contentInfos)==null?void 0:s.contentId))return;let{isDirectFile:r,manifest:i}=e;if(!r&&i===null||_(t))return;let o=i!==null?_t(i):void 0,a={position:t.position.getPolled(),duration:t.duration,playbackRate:t.playbackRate,maximumPosition:o,bufferGap:t.bufferGap===void 0||!isFinite(t.bufferGap)?0:t.bufferGap};if(i!==null&&i.isLive&&t.position.getPolled()>0){let u=(d=i.availabilityStartTime)!=null?d:0;a.wallClockTime=t.position.getPolled()+u;let c=bn(i);c!==void 0&&(a.liveGap=c-t.position.getPolled())}else if(r&&this.videoElement!==null){let u=mo(this.videoElement);u!==void 0&&(a.wallClockTime=u+t.position.getPolled())}this.trigger("positionUpdate",a)}_priv_triggerEventIfNotStopped(e,t,r){r.isCancelled()||this.trigger(e,t)}_priv_initializeMediaElementTracksStore(e){var r,i,o;ee(fe.directfile!==null,"Initializing `MediaElementTracksStore` without Directfile feature"),ee(this.videoElement!==null,"Initializing `MediaElementTracksStore` on a disposed RxPlayer");let t=new fe.directfile.mediaElementTracksStore(this.videoElement);return this._priv_triggerEventIfNotStopped("availableAudioTracksChange",t.getAvailableAudioTracks(),e),this._priv_triggerEventIfNotStopped("availableVideoTracksChange",t.getAvailableVideoTracks(),e),this._priv_triggerEventIfNotStopped("availableTextTracksChange",t.getAvailableTextTracks(),e),this._priv_triggerEventIfNotStopped("audioTrackChange",(r=t.getChosenAudioTrack())!=null?r:null,e),this._priv_triggerEventIfNotStopped("textTrackChange",(i=t.getChosenTextTrack())!=null?i:null,e),this._priv_triggerEventIfNotStopped("videoTrackChange",(o=t.getChosenVideoTrack())!=null?o:null,e),t.addEventListener("availableVideoTracksChange",a=>this.trigger("availableVideoTracksChange",a)),t.addEventListener("availableAudioTracksChange",a=>this.trigger("availableAudioTracksChange",a)),t.addEventListener("availableTextTracksChange",a=>this.trigger("availableTextTracksChange",a)),t.addEventListener("audioTrackChange",a=>this.trigger("audioTrackChange",a)),t.addEventListener("videoTrackChange",a=>this.trigger("videoTrackChange",a)),t.addEventListener("textTrackChange",a=>this.trigger("textTrackChange",a)),t}_priv_callTracksStoreGetterSetter(e,t,r){var d,u;if(this._priv_contentInfos===null||this._priv_contentInfos.tracksStore===null)return m.warn("API: Trying to call track API too soon"),t;let{tracksStore:i}=this._priv_contentInfos,o=(u=(d=this._priv_contentInfos)==null?void 0:d.currentPeriod)!=null?u:void 0,a=e!=null?e:o==null?void 0:o.id;if(a===void 0)return t;let s=a===(o==null?void 0:o.id)?i.getPeriodObjectFromPeriod(o):i.getPeriodObjectFromId(a);return s===void 0?t:r(i,s)}_priv_onAvailableTracksMayHaveChanged(e,t){let r=this._priv_contentInfos;if(r===null)return;let{currentPeriod:i,tracksStore:o,currentContentCanceller:a}=r,s=a.signal;if(_(i)||o===null)return;let d=t!=null?t:o.getPeriodObjectFromPeriod(i);if(d!==void 0)switch(e){case"video":{let u=o.getAvailableVideoTracks(d,!0);this._priv_triggerEventIfNotStopped("availableVideoTracksChange",u!=null?u:[],s);break}case"audio":{let u=o.getAvailableAudioTracks(d,!0);this._priv_triggerEventIfNotStopped("availableAudioTracksChange",u!=null?u:[],s);break}case"text":{let u=o.getAvailableTextTracks(d);this._priv_triggerEventIfNotStopped("availableTextTracksChange",u!=null?u:[],s);break}default:He(e)}}_priv_onFatalError(e,t){let r=Ee(e,{defaultCode:"NONE",defaultReason:"An unknown error stopped content playback."});r.fatal=!0,t.currentContentCanceller.cancel(),this._priv_cleanUpCurrentContentState(),this._priv_currentError=r,m.error("API: The player stopped because of an error",r),this._priv_setPlayerState("STOPPED"),this._priv_currentError===r&&this.trigger("error",r)}};Vt._priv_currentlyUsedVideoElements=new WeakSet;var za=Vt;za.version="4.3.1-dev.2025041002";var Ep=za;var Ha=Ep;Wa();Ha.addFeatures([Ul,_u,Pu,Cu,vl,bl,Cl,Tl,rl,Ou,gl,Nu]);Bn()?m.setLevel("DEBUG","full"):y.CURRENT_ENV===y.DEV&&m.setLevel(S.CURRENT_LEVEL,"standard");var use=Ha;J.RxPlayer=Ha;})();
|
package/package.json
CHANGED
|
@@ -408,7 +408,7 @@ class Player extends EventEmitter<IPublicAPIEvent> {
|
|
|
408
408
|
// See: https://bugzilla.mozilla.org/show_bug.cgi?id=1194624
|
|
409
409
|
videoElement.preload = "auto";
|
|
410
410
|
|
|
411
|
-
this.version = /* PLAYER_VERSION */ "4.3.1-dev.
|
|
411
|
+
this.version = /* PLAYER_VERSION */ "4.3.1-dev.2025041002";
|
|
412
412
|
this.log = log;
|
|
413
413
|
this.state = "STOPPED";
|
|
414
414
|
this.videoElement = videoElement;
|
|
@@ -3415,7 +3415,7 @@ class Player extends EventEmitter<IPublicAPIEvent> {
|
|
|
3415
3415
|
}
|
|
3416
3416
|
}
|
|
3417
3417
|
}
|
|
3418
|
-
Player.version = /* PLAYER_VERSION */ "4.3.1-dev.
|
|
3418
|
+
Player.version = /* PLAYER_VERSION */ "4.3.1-dev.2025041002";
|
|
3419
3419
|
|
|
3420
3420
|
/** Every events sent by the RxPlayer's public API. */
|
|
3421
3421
|
interface IPublicAPIEvent {
|