@mux/playback-core
Advanced tools
Comparing version 0.22.2-canary.0-a3662c7 to 0.22.2-canary.0-e54dcdb
@@ -36,3 +36,3 @@ { | ||
"src/autoplay.ts": { | ||
"bytes": 4533, | ||
"bytes": 5113, | ||
"imports": [ | ||
@@ -117,3 +117,3 @@ { | ||
"src/index.ts": { | ||
"bytes": 30875, | ||
"bytes": 33464, | ||
"imports": [ | ||
@@ -184,3 +184,3 @@ { | ||
"inputs": {}, | ||
"bytes": 96488 | ||
"bytes": 100960 | ||
}, | ||
@@ -204,6 +204,6 @@ "dist/index.cjs.js": { | ||
"src/index.ts": { | ||
"bytesInOutput": 10817 | ||
"bytesInOutput": 11419 | ||
}, | ||
"src/hls.ts": { | ||
"bytesInOutput": 39 | ||
"bytesInOutput": 42 | ||
}, | ||
@@ -220,3 +220,3 @@ "src/errors.ts": { | ||
"src/autoplay.ts": { | ||
"bytesInOutput": 897 | ||
"bytesInOutput": 1057 | ||
}, | ||
@@ -236,5 +236,5 @@ "src/preload.ts": { | ||
}, | ||
"bytes": 20437 | ||
"bytes": 21203 | ||
} | ||
} | ||
} |
@@ -36,3 +36,3 @@ { | ||
"src/autoplay.ts": { | ||
"bytes": 4533, | ||
"bytes": 5113, | ||
"imports": [ | ||
@@ -117,3 +117,3 @@ { | ||
"src/index.ts": { | ||
"bytes": 30875, | ||
"bytes": 33464, | ||
"imports": [ | ||
@@ -184,3 +184,3 @@ { | ||
"inputs": {}, | ||
"bytes": 94800 | ||
"bytes": 99272 | ||
}, | ||
@@ -255,3 +255,3 @@ "dist/index.mjs": { | ||
"src/index.ts": { | ||
"bytesInOutput": 9606 | ||
"bytesInOutput": 10212 | ||
}, | ||
@@ -271,3 +271,3 @@ "src/hls.ts": { | ||
"src/autoplay.ts": { | ||
"bytesInOutput": 893 | ||
"bytesInOutput": 1053 | ||
}, | ||
@@ -281,3 +281,3 @@ "src/preload.ts": { | ||
"src/text-tracks.ts": { | ||
"bytesInOutput": 3547 | ||
"bytesInOutput": 3549 | ||
}, | ||
@@ -288,5 +288,5 @@ "src/pdt.ts": { | ||
}, | ||
"bytes": 19722 | ||
"bytes": 20490 | ||
} | ||
} | ||
} |
@@ -46,3 +46,3 @@ { | ||
"src/autoplay.ts": { | ||
"bytes": 4533, | ||
"bytes": 5113, | ||
"imports": [ | ||
@@ -127,3 +127,3 @@ { | ||
"src/index.ts": { | ||
"bytes": 30875, | ||
"bytes": 33464, | ||
"imports": [ | ||
@@ -194,3 +194,3 @@ { | ||
"inputs": {}, | ||
"bytes": 1931486 | ||
"bytes": 1935958 | ||
}, | ||
@@ -206,3 +206,3 @@ "dist/playback-core.js": { | ||
"src/index.ts": { | ||
"bytesInOutput": 9695 | ||
"bytesInOutput": 10311 | ||
}, | ||
@@ -225,3 +225,3 @@ "../../node_modules/hls.js/dist/hls.mjs": { | ||
"src/autoplay.ts": { | ||
"bytesInOutput": 910 | ||
"bytesInOutput": 1074 | ||
}, | ||
@@ -241,5 +241,5 @@ "src/preload.ts": { | ||
}, | ||
"bytes": 463299 | ||
"bytes": 464079 | ||
} | ||
} | ||
} |
@@ -1,4 +0,4 @@ | ||
"use strict";var Oe=Object.create;var R=Object.defineProperty;var Ve=Object.getOwnPropertyDescriptor;var Ue=Object.getOwnPropertyNames;var Fe=Object.getPrototypeOf,We=Object.prototype.hasOwnProperty;var Be=(e,t)=>{for(var n in t)R(e,n,{get:t[n],enumerable:!0})},Q=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Ue(t))!We.call(e,o)&&o!==n&&R(e,o,{get:()=>t[o],enumerable:!(r=Ve(t,o))||r.enumerable});return e};var J=(e,t,n)=>(n=e!=null?Oe(Fe(e)):{},Q(t||!e||!e.__esModule?R(n,"default",{value:e,enumerable:!0}):n,e)),Ke=e=>Q(R({},"__esModule",{value:!0}),e);var ft={};Be(ft,{AutoplayTypes:()=>E,CmcdTypeValues:()=>qe,CmcdTypes:()=>k,ExtensionMimeTypeMap:()=>b,Hls:()=>f,MaxResolution:()=>Xe,MediaError:()=>x,MimeTypeShorthandMap:()=>h,MinResolution:()=>Ge,PlaybackTypes:()=>w,RenditionOrder:()=>je,StreamTypes:()=>v,addCuePoints:()=>F,addTextTrack:()=>H,allMediaTypes:()=>ze,generatePlayerInitTime:()=>nt,generateUUID:()=>Pe,getActiveCuePoint:()=>W,getCuePoints:()=>ue,getCuePointsTrack:()=>A,getCurrentPdt:()=>le,getEnded:()=>Ce,getError:()=>it,getLiveEdgeStart:()=>dt,getMediaPlaylistLinesFromMultivariantPlaylistSrc:()=>me,getSeekable:()=>ke,getStartDate:()=>de,getStreamInfoFromHlsjsLevelDetails:()=>ve,getStreamInfoFromPlaylistLines:()=>ge,getStreamInfoFromSrcAndType:()=>Me,getStreamType:()=>ct,getStreamTypeConfig:()=>Re,getTargetLiveWindow:()=>ut,initialize:()=>pt,isKeyOf:()=>I,isMuxVideoSrc:()=>z,isPseudoEnded:()=>he,isStuckOnLastFragment:()=>$,loadMedia:()=>we,mux:()=>D.default,muxMediaState:()=>m,removeTextTrack:()=>ie,setupCuePoints:()=>B,setupHls:()=>De,setupMux:()=>Ie,shorthandKeys:()=>$e,teardown:()=>Se,toMuxVideoURL:()=>rt,updateStreamInfoFromHlsjsLevelDetails:()=>be,updateStreamInfoFromSrc:()=>K});module.exports=Ke(ft);var D=J(require("mux-embed"));var Z=J(require("hls.js")),f=Z.default;var M=class M extends Error{constructor(n,r=M.MEDIA_ERR_CUSTOM,o,a){var i;super(n);this.name="MediaError",this.code=r,this.context=a,this.fatal=o!=null?o:r>=M.MEDIA_ERR_NETWORK&&r<=M.MEDIA_ERR_ENCRYPTED,this.message||(this.message=(i=M.defaultMessages[this.code])!=null?i:"")}};M.MEDIA_ERR_ABORTED=1,M.MEDIA_ERR_NETWORK=2,M.MEDIA_ERR_DECODE=3,M.MEDIA_ERR_SRC_NOT_SUPPORTED=4,M.MEDIA_ERR_ENCRYPTED=5,M.MEDIA_ERR_CUSTOM=100,M.defaultMessages={1:"You aborted the media playback",2:"A network error caused the media download to fail.",3:"A media error caused playback to be aborted. The media could be corrupt or your browser does not support this format.",4:"An unsupported error occurred. The server or network failed, or your browser does not support this format.",5:"The media is encrypted and there are no keys to decrypt it."};var x=M;var Ye=e=>e==null,I=(e,t)=>Ye(t)?!1:e in t,E={ANY:"any",MUTED:"muted"},v={ON_DEMAND:"on-demand",LIVE:"live",UNKNOWN:"unknown"},w={MSE:"mse",NATIVE:"native"},k={HEADER:"header",QUERY:"query",NONE:"none"},qe=Object.values(k),b={M3U8:"application/vnd.apple.mpegurl",MP4:"video/mp4"},h={HLS:b.M3U8},$e=Object.keys(h),ze=[...Object.values(b),"hls","HLS"],Xe={upTo720p:"720p",upTo1080p:"1080p",upTo1440p:"1440p",upTo2160p:"2160p"},Ge={noLessThan480p:"480p",noLessThan540p:"540p",noLessThan720p:"720p",noLessThan1080p:"1080p",noLessThan1440p:"1440p",noLessThan2160p:"2160p"},je={DESCENDING:"desc"};var g=(e,t,n,r,o=e)=>{o.addEventListener(t,n,r),e.addEventListener("teardown",()=>{o.removeEventListener(t,n)},{once:!0})};function ee(e,t,n){t&&n>t&&(n=t);for(let r=0;r<e.length;r++)if(e.start(r)<=n&&e.end(r)>=n)return!0;return!1}var te=e=>{let t=e.indexOf("?");if(t<0)return[e];let n=e.slice(0,t),r=e.slice(t);return[n,r]},C=e=>{let t=e.type;if(t){let r=t.toUpperCase();return I(r,h)?h[r]:t}let{src:n}=e;return n?Qe(n):""},_=e=>e==="VOD"?v.ON_DEMAND:v.LIVE,O=e=>e==="EVENT"?Number.POSITIVE_INFINITY:e==="VOD"?Number.NaN:0,Qe=e=>{let t="";try{t=new URL(e).pathname}catch{console.error("invalid url")}let n=t.lastIndexOf(".");if(n<0)return"";let o=t.slice(n+1).toUpperCase();return I(o,b)?b[o]:""};var Je=Object.values(E),ne=e=>typeof e=="boolean"||typeof e=="string"&&Je.includes(e),re=({autoplay:e},t,n)=>{let r=!1,o=!1,a=ne(e)?e:!!e,i=()=>{r||g(t,"playing",()=>{r=!0},{once:!0})};if(i(),g(t,"loadstart",()=>{r=!1,i(),V(t,a)},{once:!0}),g(t,"loadstart",()=>{n||(o=!Number.isFinite(t.duration)),V(t,a)},{once:!0}),n&&n.once(f.Events.LEVEL_LOADED,(d,c)=>{var l;o=(l=c.details.live)!=null?l:!1}),!a){let d=()=>{o&&(n!=null&&n.liveSyncPosition?t.currentTime=n.liveSyncPosition:Number.isFinite(t.seekable.end(0))&&(t.currentTime=t.seekable.end(0)))};n&&g(t,"play",()=>{t.preload==="metadata"?n.once(f.Events.LEVEL_UPDATED,d):d()},{once:!0})}return d=>{r||(a=ne(d)?d:!!d,V(t,a))}},V=(e,t)=>{if(!t)return;let n=e.muted,r=()=>e.muted=n;switch(t){case E.ANY:e.play().catch(()=>{e.muted=!0,e.play().catch(r)});break;case E.MUTED:e.muted=!0,e.play().catch(r);break;default:e.play().catch(()=>{});break}};var oe=({preload:e,src:t},n,r)=>{let o=u=>{u!=null&&["","none","metadata","auto"].includes(u)?n.setAttribute("preload",u):n.removeAttribute("preload")};if(!r)return o(e),o;let a=!1,i=!1,s=r.config.maxBufferLength,d=r.config.maxBufferSize,c=u=>{o(u);let p=u!=null?u:n.preload;i||p==="none"||(p==="metadata"?(r.config.maxBufferLength=1,r.config.maxBufferSize=1):(r.config.maxBufferLength=s,r.config.maxBufferSize=d),l())},l=()=>{!a&&t&&(a=!0,r.loadSource(t))};return g(n,"play",()=>{i=!0,r.config.maxBufferLength=s,r.config.maxBufferSize=d,l()},{once:!0}),c(e),c};function ae(e,t){var d;if(!("videoTracks"in e))return;let n=new WeakMap;t.on(f.Events.MANIFEST_PARSED,function(c,l){s();let u=e.addVideoTrack("main");u.selected=!0;for(let[p,T]of l.levels.entries()){let y=u.addRendition(T.url[0],T.width,T.height,T.videoCodec,T.bitrate);n.set(T,`${p}`),y.id=`${p}`}}),t.on(f.Events.AUDIO_TRACKS_UPDATED,function(c,l){i();for(let u of l.audioTracks){let p=u.default?"main":"alternative",T=e.addAudioTrack(p,u.name,u.lang);T.id=`${u.id}`,u.default&&(T.enabled=!0)}}),e.audioTracks.addEventListener("change",()=>{var u;let c=+((u=[...e.audioTracks].find(p=>p.enabled))==null?void 0:u.id),l=t.audioTracks.map(p=>p.id);c!=t.audioTrack&&l.includes(c)&&(t.audioTrack=c)}),t.on(f.Events.LEVELS_UPDATED,function(c,l){var T;let u=e.videoTracks[(T=e.videoTracks.selectedIndex)!=null?T:0];if(!u)return;let p=l.levels.map(y=>n.get(y));for(let y of e.videoRenditions)y.id&&!p.includes(y.id)&&u.removeRendition(y)});let r=c=>{let l=c.target.selectedIndex;l!=t.nextLevel&&o(l)},o=c=>{let l=e.currentTime,u=!1,p=(T,y)=>{u||(u=!Number.isFinite(y.endOffset))};t.on(f.Events.BUFFER_FLUSHING,p),t.nextLevel=c,t.off(f.Events.BUFFER_FLUSHING,p),u||t.trigger(f.Events.BUFFER_FLUSHING,{startOffset:l+10,endOffset:1/0,type:"video"})};(d=e.videoRenditions)==null||d.addEventListener("change",r);let a=()=>{for(let c of e.videoTracks)e.removeVideoTrack(c)},i=()=>{for(let c of e.audioTracks)e.removeAudioTrack(c)},s=()=>{a(),i()};t.once(f.Events.DESTROYING,s)}function se(e,t){t.on(f.Events.NON_NATIVE_TEXT_TRACKS_FOUND,(o,{tracks:a})=>{a.forEach(i=>{var c;let s=(c=i.subtitleTrack)!=null?c:i.closedCaptions,d=t.subtitleTracks.findIndex(({lang:l,name:u,type:p})=>l==(s==null?void 0:s.lang)&&u===i.label&&p.toLowerCase()===i.kind);H(e,i.kind,i.label,s==null?void 0:s.lang,`${i.kind}${d}`)})});let n=()=>{var i;if(!t.subtitleTracks.length)return;let o=Array.from(e.textTracks).find(s=>s.id&&s.mode==="showing"&&["subtitles","captions"].includes(s.kind)),a=`${(i=t.subtitleTracks[t.subtitleTrack])==null?void 0:i.type.toLowerCase()}${t.subtitleTrack}`;if(o&&(t.subtitleTrack<0||(o==null?void 0:o.id)!==a)){let s=t.subtitleTracks.findIndex(({lang:d,name:c,type:l})=>d==o.language&&c===o.label&&l.toLowerCase()===o.kind);t.subtitleTrack=s}o&&(o==null?void 0:o.id)===a&&o.cues&&Array.from(o.cues).forEach(s=>{o.addCue(s)})};e.textTracks.addEventListener("change",n),t.on(f.Events.CUES_PARSED,(o,{track:a,cues:i})=>{let s=e.textTracks.getTrackById(a);if(!s)return;let d=s.mode==="disabled";d&&(s.mode="hidden"),i.forEach(c=>{var l;(l=s.cues)!=null&&l.getCueById(c.id)||s.addCue(c)}),d&&(s.mode="disabled")}),t.once(f.Events.DESTROYING,()=>{e.textTracks.removeEventListener("change",n),e.querySelectorAll("track[data-removeondestroy]").forEach(a=>{a.remove()})});let r=()=>{Array.from(e.textTracks).forEach(o=>{var a,i;if(!["subtitles","caption"].includes(o.kind)&&o.label==="thumbnails"){if(!((a=o.cues)!=null&&a.length)){let s=e.querySelector('track[label="thumbnails"]'),d=(i=s==null?void 0:s.getAttribute("src"))!=null?i:"";s==null||s.removeAttribute("src"),setTimeout(()=>{s==null||s.setAttribute("src",d)},0)}o.mode!=="hidden"&&(o.mode="hidden")}})};t.once(f.Events.MANIFEST_LOADED,r),t.once(f.Events.MEDIA_ATTACHED,r)}function H(e,t,n,r,o){let a=document.createElement("track");return a.kind=t,a.label=n,r&&(a.srclang=r),o&&(a.id=o),a.track.mode=["subtitles","captions"].includes(t)?"disabled":"hidden",a.setAttribute("data-removeondestroy",""),e.append(a),a.track}function ie(e,t){let n=Array.prototype.find.call(e.querySelectorAll("track"),r=>r.track===t);n==null||n.remove()}var S="cuepoints",U=Object.freeze({label:S}),A=(e,{label:t=S}=U)=>{var n;return(n=Array.from(e.querySelectorAll("track")).find(r=>r.track.label===t&&r.track.kind==="metadata"))==null?void 0:n.track};async function F(e,t,n=U){let r=A(e,n);if(!r){let{label:o=S}=n;r=H(e,"metadata",o),r.mode="hidden",await new Promise(a=>setTimeout(()=>a(void 0),0))}return r.mode!=="hidden"&&(r.mode="hidden"),[...t].sort(({time:o},{time:a})=>a-o).forEach(({time:o,value:a})=>{var u,p;let i=Array.prototype.findIndex.call(r==null?void 0:r.cues,T=>T.startTime>=o),s=(u=r==null?void 0:r.cues)==null?void 0:u[i],d=s?s.startTime:Number.isFinite(e.duration)?e.duration:Number.MAX_SAFE_INTEGER,c=(p=r==null?void 0:r.cues)==null?void 0:p[i-1];c&&(c.endTime=o);let l=new VTTCue(o,d,JSON.stringify(a!=null?a:null));r.addCue(l)}),r}var ce=e=>({time:e.startTime,value:JSON.parse(e.text)});function ue(e,t={label:S}){let n=A(e,t);return n!=null&&n.cues?Array.from(n.cues,r=>ce(r)):[]}function W(e,t={label:S}){var a,i;let n=A(e,t);if(!((a=n==null?void 0:n.activeCues)!=null&&a.length))return;let{currentTime:r}=e,o=Array.prototype.find.call((i=n.activeCues)!=null?i:[],({startTime:s,endTime:d})=>s<=r&&d>r);return ce(o)}async function B(e,t=U){return new Promise(n=>{g(e,"loadstart",async()=>{let r=await F(e,[],t);g(e,"cuechange",()=>{let o=W(e);if(o){let a=new CustomEvent("cuepointchange",{composed:!0,bubbles:!0,detail:o});e.dispatchEvent(a)}},{},r),n(r)})})}function de(e,t){if(t){let n=t.playingDate;if(n!=null)return new Date(n.getTime()-e.currentTime*1e3)}return typeof e.getStartDate=="function"?e.getStartDate():new Date(NaN)}function le(e,t){if(t&&t.playingDate)return t.playingDate;if(typeof e.getStartDate=="function"){let n=e.getStartDate();return new Date(n.getTime()+e.currentTime*1e3)}return new Date(NaN)}var me=async e=>fetch(e).then(t=>t.text()).then(t=>{let n=t.split(` | ||
"use strict";var Ve=Object.create;var I=Object.defineProperty;var Ue=Object.getOwnPropertyDescriptor;var Fe=Object.getOwnPropertyNames;var We=Object.getPrototypeOf,Be=Object.prototype.hasOwnProperty;var Ke=(t,e)=>{for(var n in e)I(t,n,{get:e[n],enumerable:!0})},Z=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Fe(e))!Be.call(t,o)&&o!==n&&I(t,o,{get:()=>e[o],enumerable:!(r=Ue(e,o))||r.enumerable});return t};var ee=(t,e,n)=>(n=t!=null?Ve(We(t)):{},Z(e||!t||!t.__esModule?I(n,"default",{value:t,enumerable:!0}):n,t)),Ye=t=>Z(I({},"__esModule",{value:!0}),t);var ft={};Ke(ft,{AutoplayTypes:()=>E,CmcdTypeValues:()=>$e,CmcdTypes:()=>k,ExtensionMimeTypeMap:()=>b,Hls:()=>T,MaxResolution:()=>Ge,MediaError:()=>x,MimeTypeShorthandMap:()=>h,MinResolution:()=>je,PlaybackTypes:()=>R,RenditionOrder:()=>Qe,StreamTypes:()=>m,addCuePoints:()=>W,addTextTrack:()=>w,allMediaTypes:()=>Xe,generatePlayerInitTime:()=>rt,generateUUID:()=>Ee,getActiveCuePoint:()=>B,getCuePoints:()=>le,getCuePointsTrack:()=>A,getCurrentPdt:()=>fe,getEnded:()=>Ce,getError:()=>ct,getLiveEdgeStart:()=>dt,getMediaPlaylistLinesFromMultivariantPlaylistSrc:()=>Me,getSeekable:()=>H,getStartDate:()=>pe,getStreamInfoFromHlsjsLevelDetails:()=>xe,getStreamInfoFromPlaylistLines:()=>ve,getStreamInfoFromSrcAndType:()=>be,getStreamType:()=>q,getStreamTypeConfig:()=>Ne,getTargetLiveWindow:()=>ut,initialize:()=>pt,isKeyOf:()=>N,isMuxVideoSrc:()=>G,isPseudoEnded:()=>Se,isStuckOnLastFragment:()=>X,loadMedia:()=>we,mux:()=>D.default,muxMediaState:()=>M,removeTextTrack:()=>ue,setupCuePoints:()=>K,setupHls:()=>Ie,setupMux:()=>Re,shorthandKeys:()=>ze,teardown:()=>Ae,toMuxVideoURL:()=>ot,updateStreamInfoFromHlsjsLevelDetails:()=>Le,updateStreamInfoFromSrc:()=>Y});module.exports=Ye(ft);var D=ee(require("mux-embed"));var te=ee(require("hls.js")),T=te.default;var v=class v extends Error{constructor(n,r=v.MEDIA_ERR_CUSTOM,o,a){var c;super(n);this.name="MediaError",this.code=r,this.context=a,this.fatal=o!=null?o:r>=v.MEDIA_ERR_NETWORK&&r<=v.MEDIA_ERR_ENCRYPTED,this.message||(this.message=(c=v.defaultMessages[this.code])!=null?c:"")}};v.MEDIA_ERR_ABORTED=1,v.MEDIA_ERR_NETWORK=2,v.MEDIA_ERR_DECODE=3,v.MEDIA_ERR_SRC_NOT_SUPPORTED=4,v.MEDIA_ERR_ENCRYPTED=5,v.MEDIA_ERR_CUSTOM=100,v.defaultMessages={1:"You aborted the media playback",2:"A network error caused the media download to fail.",3:"A media error caused playback to be aborted. The media could be corrupt or your browser does not support this format.",4:"An unsupported error occurred. The server or network failed, or your browser does not support this format.",5:"The media is encrypted and there are no keys to decrypt it."};var x=v;var qe=t=>t==null,N=(t,e)=>qe(e)?!1:t in e,E={ANY:"any",MUTED:"muted"},m={ON_DEMAND:"on-demand",LIVE:"live",UNKNOWN:"unknown"},R={MSE:"mse",NATIVE:"native"},k={HEADER:"header",QUERY:"query",NONE:"none"},$e=Object.values(k),b={M3U8:"application/vnd.apple.mpegurl",MP4:"video/mp4"},h={HLS:b.M3U8},ze=Object.keys(h),Xe=[...Object.values(b),"hls","HLS"],Ge={upTo720p:"720p",upTo1080p:"1080p",upTo1440p:"1440p",upTo2160p:"2160p"},je={noLessThan480p:"480p",noLessThan540p:"540p",noLessThan720p:"720p",noLessThan1080p:"1080p",noLessThan1440p:"1440p",noLessThan2160p:"2160p"},Qe={DESCENDING:"desc"};var g=(t,e,n,r,o=t)=>{o.addEventListener(e,n,r),t.addEventListener("teardown",()=>{o.removeEventListener(e,n)},{once:!0})};function ne(t,e,n){e&&n>e&&(n=e);for(let r=0;r<t.length;r++)if(t.start(r)<=n&&t.end(r)>=n)return!0;return!1}var re=t=>{let e=t.indexOf("?");if(e<0)return[t];let n=t.slice(0,e),r=t.slice(e);return[n,r]},S=t=>{let e=t.type;if(e){let r=e.toUpperCase();return N(r,h)?h[r]:e}let{src:n}=t;return n?Je(n):""},O=t=>t==="VOD"?m.ON_DEMAND:m.LIVE,V=t=>t==="EVENT"?Number.POSITIVE_INFINITY:t==="VOD"?Number.NaN:0,Je=t=>{let e="";try{e=new URL(t).pathname}catch{console.error("invalid url")}let n=e.lastIndexOf(".");if(n<0)return"";let o=e.slice(n+1).toUpperCase();return N(o,b)?b[o]:""};var Ze=Object.values(E),oe=t=>typeof t=="boolean"||typeof t=="string"&&Ze.includes(t),ae=(t,e,n)=>{let{autoplay:r}=t,o=!1,a=!1,c=oe(r)?r:!!r,i=()=>{o||g(e,"playing",()=>{o=!0},{once:!0})};if(i(),g(e,"loadstart",()=>{o=!1,i(),U(e,c)},{once:!0}),g(e,"loadstart",()=>{n||(t.streamType&&t.streamType!==m.UNKNOWN?a=t.streamType===m.LIVE:a=!Number.isFinite(e.duration)),U(e,c)},{once:!0}),n&&n.once(T.Events.LEVEL_LOADED,(u,d)=>{var s;t.streamType&&t.streamType!==m.UNKNOWN?a=t.streamType===m.LIVE:a=(s=d.details.live)!=null?s:!1}),!c){let u=()=>{!a||Number.isFinite(t.startTime)||(n!=null&&n.liveSyncPosition?e.currentTime=n.liveSyncPosition:Number.isFinite(e.seekable.end(0))&&(e.currentTime=e.seekable.end(0)))};n&&g(e,"play",()=>{e.preload==="metadata"?n.once(T.Events.LEVEL_UPDATED,u):u()},{once:!0})}return u=>{o||(c=oe(u)?u:!!u,U(e,c))}},U=(t,e)=>{if(!e)return;let n=t.muted,r=()=>t.muted=n;switch(e){case E.ANY:t.play().catch(()=>{t.muted=!0,t.play().catch(r)});break;case E.MUTED:t.muted=!0,t.play().catch(r);break;default:t.play().catch(()=>{});break}};var se=({preload:t,src:e},n,r)=>{let o=s=>{s!=null&&["","none","metadata","auto"].includes(s)?n.setAttribute("preload",s):n.removeAttribute("preload")};if(!r)return o(t),o;let a=!1,c=!1,i=r.config.maxBufferLength,p=r.config.maxBufferSize,u=s=>{o(s);let l=s!=null?s:n.preload;c||l==="none"||(l==="metadata"?(r.config.maxBufferLength=1,r.config.maxBufferSize=1):(r.config.maxBufferLength=i,r.config.maxBufferSize=p),d())},d=()=>{!a&&e&&(a=!0,r.loadSource(e))};return g(n,"play",()=>{c=!0,r.config.maxBufferLength=i,r.config.maxBufferSize=p,d()},{once:!0}),u(t),u};function ie(t,e){var p;if(!("videoTracks"in t))return;let n=new WeakMap;e.on(T.Events.MANIFEST_PARSED,function(u,d){i();let s=t.addVideoTrack("main");s.selected=!0;for(let[l,f]of d.levels.entries()){let y=s.addRendition(f.url[0],f.width,f.height,f.videoCodec,f.bitrate);n.set(f,`${l}`),y.id=`${l}`}}),e.on(T.Events.AUDIO_TRACKS_UPDATED,function(u,d){c();for(let s of d.audioTracks){let l=s.default?"main":"alternative",f=t.addAudioTrack(l,s.name,s.lang);f.id=`${s.id}`,s.default&&(f.enabled=!0)}}),t.audioTracks.addEventListener("change",()=>{var s;let u=+((s=[...t.audioTracks].find(l=>l.enabled))==null?void 0:s.id),d=e.audioTracks.map(l=>l.id);u!=e.audioTrack&&d.includes(u)&&(e.audioTrack=u)}),e.on(T.Events.LEVELS_UPDATED,function(u,d){var f;let s=t.videoTracks[(f=t.videoTracks.selectedIndex)!=null?f:0];if(!s)return;let l=d.levels.map(y=>n.get(y));for(let y of t.videoRenditions)y.id&&!l.includes(y.id)&&s.removeRendition(y)});let r=u=>{let d=u.target.selectedIndex;d!=e.nextLevel&&o(d)},o=u=>{let d=t.currentTime,s=!1,l=(f,y)=>{s||(s=!Number.isFinite(y.endOffset))};e.on(T.Events.BUFFER_FLUSHING,l),e.nextLevel=u,e.off(T.Events.BUFFER_FLUSHING,l),s||e.trigger(T.Events.BUFFER_FLUSHING,{startOffset:d+10,endOffset:1/0,type:"video"})};(p=t.videoRenditions)==null||p.addEventListener("change",r);let a=()=>{for(let u of t.videoTracks)t.removeVideoTrack(u)},c=()=>{for(let u of t.audioTracks)t.removeAudioTrack(u)},i=()=>{a(),c()};e.once(T.Events.DESTROYING,i)}function ce(t,e){e.on(T.Events.NON_NATIVE_TEXT_TRACKS_FOUND,(o,{tracks:a})=>{a.forEach(c=>{var u;let i=(u=c.subtitleTrack)!=null?u:c.closedCaptions,p=e.subtitleTracks.findIndex(({lang:d,name:s,type:l})=>d==(i==null?void 0:i.lang)&&s===c.label&&l.toLowerCase()===c.kind);w(t,c.kind,c.label,i==null?void 0:i.lang,`${c.kind}${p}`)})});let n=()=>{var c;if(!e.subtitleTracks.length)return;let o=Array.from(t.textTracks).find(i=>i.id&&i.mode==="showing"&&["subtitles","captions"].includes(i.kind)),a=`${(c=e.subtitleTracks[e.subtitleTrack])==null?void 0:c.type.toLowerCase()}${e.subtitleTrack}`;if(o&&(e.subtitleTrack<0||(o==null?void 0:o.id)!==a)){let i=e.subtitleTracks.findIndex(({lang:p,name:u,type:d})=>p==o.language&&u===o.label&&d.toLowerCase()===o.kind);e.subtitleTrack=i}o&&(o==null?void 0:o.id)===a&&o.cues&&Array.from(o.cues).forEach(i=>{o.addCue(i)})};t.textTracks.addEventListener("change",n),e.on(T.Events.CUES_PARSED,(o,{track:a,cues:c})=>{let i=t.textTracks.getTrackById(a);if(!i)return;let p=i.mode==="disabled";p&&(i.mode="hidden"),c.forEach(u=>{var d;(d=i.cues)!=null&&d.getCueById(u.id)||i.addCue(u)}),p&&(i.mode="disabled")}),e.once(T.Events.DESTROYING,()=>{t.textTracks.removeEventListener("change",n),t.querySelectorAll("track[data-removeondestroy]").forEach(a=>{a.remove()})});let r=()=>{Array.from(t.textTracks).forEach(o=>{var a,c;if(!["subtitles","caption"].includes(o.kind)&&o.label==="thumbnails"){if(!((a=o.cues)!=null&&a.length)){let i=t.querySelector('track[label="thumbnails"]'),p=(c=i==null?void 0:i.getAttribute("src"))!=null?c:"";i==null||i.removeAttribute("src"),setTimeout(()=>{i==null||i.setAttribute("src",p)},0)}o.mode!=="hidden"&&(o.mode="hidden")}})};e.once(T.Events.MANIFEST_LOADED,r),e.once(T.Events.MEDIA_ATTACHED,r)}function w(t,e,n,r,o){let a=document.createElement("track");return a.kind=e,a.label=n,r&&(a.srclang=r),o&&(a.id=o),a.track.mode=["subtitles","captions"].includes(e)?"disabled":"hidden",a.setAttribute("data-removeondestroy",""),t.append(a),a.track}function ue(t,e){let n=Array.prototype.find.call(t.querySelectorAll("track"),r=>r.track===e);n==null||n.remove()}var C="cuepoints",F=Object.freeze({label:C}),A=(t,{label:e=C}=F)=>{var n;return(n=Array.from(t.querySelectorAll("track")).find(r=>r.track.label===e&&r.track.kind==="metadata"))==null?void 0:n.track};async function W(t,e,n=F){let r=A(t,n);if(!r){let{label:o=C}=n;r=w(t,"metadata",o),r.mode="hidden",await new Promise(a=>setTimeout(()=>a(void 0),0))}return r.mode!=="hidden"&&(r.mode="hidden"),[...e].sort(({time:o},{time:a})=>a-o).forEach(({time:o,value:a})=>{var s,l;let c=Array.prototype.findIndex.call(r==null?void 0:r.cues,f=>f.startTime>=o),i=(s=r==null?void 0:r.cues)==null?void 0:s[c],p=i?i.startTime:Number.isFinite(t.duration)?t.duration:Number.MAX_SAFE_INTEGER,u=(l=r==null?void 0:r.cues)==null?void 0:l[c-1];u&&(u.endTime=o);let d=new VTTCue(o,p,JSON.stringify(a!=null?a:null));r.addCue(d)}),r}var de=t=>({time:t.startTime,value:JSON.parse(t.text)});function le(t,e={label:C}){let n=A(t,e);return n!=null&&n.cues?Array.from(n.cues,r=>de(r)):[]}function B(t,e={label:C}){var a,c;let n=A(t,e);if(!((a=n==null?void 0:n.activeCues)!=null&&a.length))return;let{currentTime:r}=t,o=Array.prototype.find.call((c=n.activeCues)!=null?c:[],({startTime:i,endTime:p})=>i<=r&&p>r);return de(o)}async function K(t,e=F){return new Promise(n=>{g(t,"loadstart",async()=>{let r=await W(t,[],e);g(t,"cuechange",()=>{let o=B(t);if(o){let a=new CustomEvent("cuepointchange",{composed:!0,bubbles:!0,detail:o});t.dispatchEvent(a)}},{},r),n(r)})})}function pe(t,e){if(e){let n=e.playingDate;if(n!=null)return new Date(n.getTime()-t.currentTime*1e3)}return typeof t.getStartDate=="function"?t.getStartDate():new Date(NaN)}function fe(t,e){if(e&&e.playingDate)return e.playingDate;if(typeof t.getStartDate=="function"){let n=t.getStartDate();return new Date(n.getTime()+t.currentTime*1e3)}return new Date(NaN)}var Me=async t=>fetch(t).then(e=>e.text()).then(e=>{let n=e.split(` | ||
`).find((r,o,a)=>o&&a[o-1].startsWith("#EXT-X-STREAM-INF"));return fetch(n).then(r=>r.text()).then(r=>r.split(` | ||
`))}),ge=e=>{var i,s,d;let n=(s=((i=e.find(c=>c.startsWith("#EXT-X-PLAYLIST-TYPE")))!=null?i:"").split(":")[1])==null?void 0:s.trim(),r=_(n),o=O(n),a;if(r===v.LIVE){let c=e.find(u=>u.startsWith("#EXT-X-PART-INF"));if(!!c)a=+c.split(":")[1].split("=")[1]*2;else{let u=e.find(y=>y.startsWith("#EXT-X-TARGETDURATION")),p=(d=u==null?void 0:u.split(":"))==null?void 0:d[1];a=+(p!=null?p:6)*3}}return{streamType:r,targetLiveWindow:o,liveEdgeStartOffset:a}},Me=async(e,t)=>{if(t===b.MP4)return{streamType:v.ON_DEMAND,targetLiveWindow:Number.NaN,liveEdgeStartOffset:void 0};if(t===b.M3U8){let n=await me(e);return ge(n)}return console.error(`Media type ${t} is an unrecognized or unsupported type for src ${e}.`),{streamType:void 0,targetLiveWindow:void 0,liveEdgeStartOffset:void 0}},K=async(e,t,n=C({src:e}))=>{var i,s,d;let{streamType:r,targetLiveWindow:o,liveEdgeStartOffset:a}=await Me(e,n);((i=m.get(t))!=null?i:{}).liveEdgeStartOffset=a,((s=m.get(t))!=null?s:{}).targetLiveWindow=o,t.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0})),((d=m.get(t))!=null?d:{}).streamType=r,t.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}))},ve=e=>{var i;let t=e.type,n=_(t),r=O(t),o,a=!!((i=e.partList)!=null&&i.length);return n===v.LIVE&&(o=a?e.partTarget*2:e.targetduration*3),{streamType:n,targetLiveWindow:r,liveEdgeStartOffset:o,lowLatency:a}},be=(e,t,n)=>{var s,d,c,l,u,p,T,y;let{streamType:r,targetLiveWindow:o,liveEdgeStartOffset:a,lowLatency:i}=ve(e);if(r===v.LIVE){i?(n.config.backBufferLength=(s=n.userConfig.backBufferLength)!=null?s:4,n.config.maxFragLookUpTolerance=(d=n.userConfig.maxFragLookUpTolerance)!=null?d:.001,n.config.abrBandWidthUpFactor=(c=n.userConfig.abrBandWidthUpFactor)!=null?c:n.config.abrBandWidthFactor):n.config.backBufferLength=(l=n.userConfig.backBufferLength)!=null?l:8;let N=Object.freeze({get length(){return t.seekable.length},start(L){return t.seekable.start(L)},end(L){var P;return L>this.length?t.seekable.end(L):(P=n.liveSyncPosition)!=null?P:t.seekable.end(L)}});((u=m.get(t))!=null?u:{}).seekable=N}((p=m.get(t))!=null?p:{}).liveEdgeStartOffset=a,((T=m.get(t))!=null?T:{}).targetLiveWindow=o,t.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0})),((y=m.get(t))!=null?y:{}).streamType=r,t.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}))},pe,fe,Ze=(fe=(pe=globalThis==null?void 0:globalThis.navigator)==null?void 0:pe.userAgent)!=null?fe:"",et=Ze.toLowerCase().indexOf("android")!==-1,m=new WeakMap,xe="mux.com",Te,ye,Le=(ye=(Te=f).isSupported)==null?void 0:ye.call(Te),tt=et,nt=()=>D.default.utils.now(),Pe=D.default.utils.generateUUID,rt=({playbackId:e,customDomain:t=xe,maxResolution:n,minResolution:r,renditionOrder:o,tokens:{playback:a}={},extraSourceParams:i={}}={})=>{if(!e)return;let[s,d=""]=te(e),c=new URL(`https://stream.${t}/${s}.m3u8${d}`);return a||c.searchParams.has("token")?(c.searchParams.forEach((l,u)=>{u!="token"&&c.searchParams.delete(u)}),a&&c.searchParams.set("token",a)):(n&&c.searchParams.set("max_resolution",n),r&&(c.searchParams.set("min_resolution",r),n&&+n.slice(0,-1)<+r.slice(0,-1)&&console.error("minResolution must be <= maxResolution","minResolution",r,"maxResolution",n)),o&&c.searchParams.set("rendition_order",o),Object.entries(i).forEach(([l,u])=>{u!=null&&c.searchParams.set(l,u)})),c.toString()},ot=e=>{if(!e)return;let[t]=e.split("?");return t||void 0},at=e=>{if(!e||!e.startsWith("https://stream."))return;let[t]=new URL(e).pathname.slice(1).split(".m3u8");return t||void 0},st=e=>{var t,n,r;return(t=e==null?void 0:e.metadata)!=null&&t.video_id?e.metadata.video_id:z(e)&&(r=(n=ot(e.playbackId))!=null?n:at(e.src))!=null?r:e.src},it=e=>{var t;return(t=m.get(e))==null?void 0:t.error},ct=e=>{var t,n;return(n=(t=m.get(e))==null?void 0:t.streamType)!=null?n:v.UNKNOWN},ut=e=>{var t,n;return(n=(t=m.get(e))==null?void 0:t.targetLiveWindow)!=null?n:Number.NaN},ke=e=>{var t,n;return(n=(t=m.get(e))==null?void 0:t.seekable)!=null?n:e.seekable},dt=e=>{var r;let t=(r=m.get(e))==null?void 0:r.liveEdgeStartOffset;if(typeof t!="number")return Number.NaN;let n=ke(e);return n.length?n.end(n.length-1)-t:Number.NaN},q=.034,lt=(e,t,n=q)=>Math.abs(e-t)<=n,Ee=(e,t,n=q)=>e>t||lt(e,t,n),he=(e,t=q)=>e.paused&&Ee(e.currentTime,e.duration,t),$=(e,t)=>{var c,l,u;if(!t)return;if(e.readyState>2)return!1;let n=t.currentLevel>=0?(l=(c=t.levels)==null?void 0:c[t.currentLevel])==null?void 0:l.details:(u=t.levels.find(p=>!!p.details))==null?void 0:u.details;if(!n||n.live)return;let{fragments:r}=n;if(!(r!=null&&r.length))return;if(e.currentTime<e.duration-(n.targetduration+.5))return!1;let o=r[r.length-1];if(e.currentTime<=o.start)return!1;let a=o.start+o.duration/2,i=e.buffered.start(e.buffered.length-1),s=e.buffered.end(e.buffered.length-1);return a>i&&a<s},Ce=(e,t)=>e.ended||e.loop?e.ended:t&&$(e,t)?!0:he(e),pt=(e,t,n)=>{Se(t,n);let{metadata:r={}}=e,{view_session_id:o=Pe()}=r,a=st(e);r.view_session_id=o,r.video_id=a,e.metadata=r,m.set(t,{});let i=De(e,t);Ie(e,t,i),we(e,t,i),B(t);let s=re(e,t,i),d=oe(e,t,i);return{engine:i,setAutoplay:s,setPreload:d}},Se=(e,t)=>{let n=t==null?void 0:t.engine;n&&(n.detachMedia(),n.destroy()),e!=null&&e.mux&&!e.mux.deleted&&(e.mux.destroy(),delete e.mux),e&&(e.removeAttribute("src"),e.load(),e.removeEventListener("error",Ne),e.removeEventListener("error",Y),e.removeEventListener("durationchange",He),m.delete(e),e.dispatchEvent(new Event("teardown")))};function Ae(e,t){var c;let n=C(e);if(!(n===b.M3U8))return!0;let o=!n||((c=t.canPlayType(n))!=null?c:!0),{preferPlayback:a}=e,i=a===w.MSE,s=a===w.NATIVE;return o&&(s||!(Le&&(i||tt)))}var De=(e,t)=>{let{debug:n,streamType:r,startTime:o=-1,metadata:a,preferCmcd:i,_hlsConfig:s={}}=e,c=C(e)===b.M3U8,l=Ae(e,t);if(c&&!l&&Le){let u={backBufferLength:30,renderTextTracksNatively:!1,liveDurationInfinity:!0,capLevelToPlayerSize:!0,capLevelOnFPSDrop:!0},p=Re(r),T=i!==k.NONE?{useHeaders:i===k.HEADER,sessionId:a==null?void 0:a.view_session_id,contentId:a==null?void 0:a.video_id}:void 0;return new f({debug:n,startPosition:o,cmcd:T,xhrSetup:(N,L)=>{var X,G;if(i&&i!==k.QUERY)return;let P=new URL(L);if(!P.searchParams.has("CMCD"))return;let _e=((G=(X=P.searchParams.get("CMCD"))==null?void 0:X.split(","))!=null?G:[]).filter(j=>j.startsWith("sid")||j.startsWith("cid")).join(",");P.searchParams.set("CMCD",_e),N.open("GET",P)},...u,...p,...s})}},Re=e=>e===v.LIVE?{backBufferLength:8}:{},z=({playbackId:e,src:t,customDomain:n})=>{if(e)return!0;if(typeof t!="string")return!1;let r=window==null?void 0:window.location.href,o=new URL(t,r).hostname.toLocaleLowerCase();return o.includes(xe)||!!n&&o.includes(n.toLocaleLowerCase())},Ie=(e,t,n)=>{var a;let{envKey:r}=e,o=z(e);if(r||o){let{playerInitTime:i,playerSoftwareName:s,playerSoftwareVersion:d,beaconCollectionDomain:c,debug:l,disableCookies:u}=e,p={...e.metadata,video_title:((a=e==null?void 0:e.metadata)==null?void 0:a.video_title)||void 0},T=y=>typeof y.player_error_code=="string"?!1:typeof e.errorTranslator=="function"?e.errorTranslator(y):y;D.default.monitor(t,{debug:l,beaconCollectionDomain:c,hlsjs:n,Hls:n?f:void 0,automaticErrorTracking:!1,errorTranslator:T,disableCookies:u,data:{...r?{env_key:r}:{},player_software_name:s,player_software:s,player_software_version:d,player_init_time:i,...p}})}},we=(e,t,n)=>{var i;let r=Ae(e,t),{src:o}=e,a=s=>{t.ended||!Ce(t,n)||($(t,n)?t.currentTime=t.buffered.end(t.buffered.length-1):t.dispatchEvent(new Event("ended")))};if(t&&r){let s=C(e);typeof o=="string"?(t.preload==="none"?g(t,"loadstart",()=>K(o,t,s)):K(o,t,s),t.setAttribute("src",o),e.startTime&&(((i=m.get(t))!=null?i:{}).startTime=e.startTime,t.addEventListener("durationchange",He,{once:!0}))):t.removeAttribute("src"),t.addEventListener("error",Ne),t.addEventListener("error",Y),t.addEventListener("emptied",()=>{t.querySelectorAll("track[data-removeondestroy]").forEach(c=>{c.remove()})},{once:!0}),g(t,"pause",a),g(t,"seeked",a),g(t,"play",()=>{t.ended||Ee(t.currentTime,t.duration)&&(t.currentTime=t.seekable.start(0))})}else n&&o?(n.once(f.Events.LEVEL_LOADED,(s,d)=>{be(d.details,t,n)}),n.on(f.Events.ERROR,(s,d)=>{let c={[f.ErrorTypes.NETWORK_ERROR]:x.MEDIA_ERR_NETWORK,[f.ErrorTypes.MEDIA_ERROR]:x.MEDIA_ERR_DECODE},l=new x("",c[d.type]);l.fatal=d.fatal,l.data=d,t.dispatchEvent(new CustomEvent("error",{detail:l}))}),t.addEventListener("error",Y),g(t,"waiting",a),ae(e,n),se(t,n),n.attachMedia(t)):console.error("It looks like the video you're trying to play will not work on this system! If possible, try upgrading to the newest versions of your browser or software.")};function He(e){var r;let t=e.target,n=(r=m.get(t))==null?void 0:r.startTime;if(n&&ee(t.seekable,t.duration,n)){let o=t.preload==="auto";o&&(t.preload="none"),t.currentTime=n,o&&(t.preload="auto")}}async function Ne(e){if(!e.isTrusted)return;e.stopImmediatePropagation();let t=e.target;if(!(t!=null&&t.error))return;let{message:n,code:r}=t.error,o=new x(n,r);if(t.src&&(r!==x.MEDIA_ERR_DECODE||r!==void 0))try{let{status:a}=await fetch(t.src);o.data={response:{code:a}}}catch{}t.dispatchEvent(new CustomEvent("error",{detail:o}))}function Y(e){var r,o;if(!(e instanceof CustomEvent)||!(e.detail instanceof x))return;let t=e.target,n=e.detail;!n||!n.fatal||(((r=m.get(t))!=null?r:{}).error=n,(o=t.mux)==null||o.emit("error",{player_error_code:n.code,player_error_message:n.message,player_error_context:n.context}))} | ||
`))}),ve=t=>{var c,i,p;let n=(i=((c=t.find(u=>u.startsWith("#EXT-X-PLAYLIST-TYPE")))!=null?c:"").split(":")[1])==null?void 0:i.trim(),r=O(n),o=V(n),a;if(r===m.LIVE){let u=t.find(s=>s.startsWith("#EXT-X-PART-INF"));if(!!u)a=+u.split(":")[1].split("=")[1]*2;else{let s=t.find(y=>y.startsWith("#EXT-X-TARGETDURATION")),l=(p=s==null?void 0:s.split(":"))==null?void 0:p[1];a=+(l!=null?l:6)*3}}return{streamType:r,targetLiveWindow:o,liveEdgeStartOffset:a}},be=async(t,e)=>{if(e===b.MP4)return{streamType:m.ON_DEMAND,targetLiveWindow:Number.NaN,liveEdgeStartOffset:void 0};if(e===b.M3U8){let n=await Me(t);return ve(n)}return console.error(`Media type ${e} is an unrecognized or unsupported type for src ${t}.`),{streamType:void 0,targetLiveWindow:void 0,liveEdgeStartOffset:void 0}},Y=async(t,e,n=S({src:t}))=>{var c,i,p;let{streamType:r,targetLiveWindow:o,liveEdgeStartOffset:a}=await be(t,n);((c=M.get(e))!=null?c:{}).liveEdgeStartOffset=a,((i=M.get(e))!=null?i:{}).targetLiveWindow=o,e.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0})),((p=M.get(e))!=null?p:{}).streamType=r,e.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}))},xe=t=>{var c;let e=t.type,n=O(e),r=V(e),o,a=!!((c=t.partList)!=null&&c.length);return n===m.LIVE&&(o=a?t.partTarget*2:t.targetduration*3),{streamType:n,targetLiveWindow:r,liveEdgeStartOffset:o,lowLatency:a}},Le=(t,e,n)=>{var i,p,u,d,s,l,f,y;let{streamType:r,targetLiveWindow:o,liveEdgeStartOffset:a,lowLatency:c}=xe(t);if(r===m.LIVE){c?(n.config.backBufferLength=(i=n.userConfig.backBufferLength)!=null?i:4,n.config.maxFragLookUpTolerance=(p=n.userConfig.maxFragLookUpTolerance)!=null?p:.001,n.config.abrBandWidthUpFactor=(u=n.userConfig.abrBandWidthUpFactor)!=null?u:n.config.abrBandWidthFactor):n.config.backBufferLength=(d=n.userConfig.backBufferLength)!=null?d:8;let _=Object.freeze({get length(){return e.seekable.length},start(L){return e.seekable.start(L)},end(L){var P;return L>this.length?e.seekable.end(L):(P=n.liveSyncPosition)!=null?P:e.seekable.end(L)}});((s=M.get(e))!=null?s:{}).seekable=_}((l=M.get(e))!=null?l:{}).liveEdgeStartOffset=a,((f=M.get(e))!=null?f:{}).targetLiveWindow=o,e.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0})),((y=M.get(e))!=null?y:{}).streamType=r,e.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}))},Te,ye,et=(ye=(Te=globalThis==null?void 0:globalThis.navigator)==null?void 0:Te.userAgent)!=null?ye:"",tt=et.toLowerCase().indexOf("android")!==-1,M=new WeakMap,Pe="mux.com",me,ge,ke=(ge=(me=T).isSupported)==null?void 0:ge.call(me),nt=tt,rt=()=>D.default.utils.now(),Ee=D.default.utils.generateUUID,ot=({playbackId:t,customDomain:e=Pe,maxResolution:n,minResolution:r,renditionOrder:o,tokens:{playback:a}={},extraSourceParams:c={}}={})=>{if(!t)return;let[i,p=""]=re(t),u=new URL(`https://stream.${e}/${i}.m3u8${p}`);return a||u.searchParams.has("token")?(u.searchParams.forEach((d,s)=>{s!="token"&&u.searchParams.delete(s)}),a&&u.searchParams.set("token",a)):(n&&u.searchParams.set("max_resolution",n),r&&(u.searchParams.set("min_resolution",r),n&&+n.slice(0,-1)<+r.slice(0,-1)&&console.error("minResolution must be <= maxResolution","minResolution",r,"maxResolution",n)),o&&u.searchParams.set("rendition_order",o),Object.entries(c).forEach(([d,s])=>{s!=null&&u.searchParams.set(d,s)})),u.toString()},at=t=>{if(!t)return;let[e]=t.split("?");return e||void 0},st=t=>{if(!t||!t.startsWith("https://stream."))return;let[e]=new URL(t).pathname.slice(1).split(".m3u8");return e||void 0},it=t=>{var e,n,r;return(e=t==null?void 0:t.metadata)!=null&&e.video_id?t.metadata.video_id:G(t)&&(r=(n=at(t.playbackId))!=null?n:st(t.src))!=null?r:t.src},ct=t=>{var e;return(e=M.get(t))==null?void 0:e.error},q=t=>{var e,n;return(n=(e=M.get(t))==null?void 0:e.streamType)!=null?n:m.UNKNOWN},ut=t=>{var e,n;return(n=(e=M.get(t))==null?void 0:e.targetLiveWindow)!=null?n:Number.NaN},H=t=>{var e,n;return(n=(e=M.get(t))==null?void 0:e.seekable)!=null?n:t.seekable},dt=t=>{var r;let e=(r=M.get(t))==null?void 0:r.liveEdgeStartOffset;if(typeof e!="number")return Number.NaN;let n=H(t);return n.length?n.end(n.length-1)-e:Number.NaN},z=.034,lt=(t,e,n=z)=>Math.abs(t-e)<=n,he=(t,e,n=z)=>t>e||lt(t,e,n),Se=(t,e=z)=>t.paused&&he(t.currentTime,t.duration,e),X=(t,e)=>{var u,d,s;if(!e)return;if(t.readyState>2)return!1;let n=e.currentLevel>=0?(d=(u=e.levels)==null?void 0:u[e.currentLevel])==null?void 0:d.details:(s=e.levels.find(l=>!!l.details))==null?void 0:s.details;if(!n||n.live)return;let{fragments:r}=n;if(!(r!=null&&r.length))return;if(t.currentTime<t.duration-(n.targetduration+.5))return!1;let o=r[r.length-1];if(t.currentTime<=o.start)return!1;let a=o.start+o.duration/2,c=t.buffered.start(t.buffered.length-1),i=t.buffered.end(t.buffered.length-1);return a>c&&a<i},Ce=(t,e)=>t.ended||t.loop?t.ended:e&&X(t,e)?!0:Se(t),pt=(t,e,n)=>{Ae(e,n);let{metadata:r={}}=t,{view_session_id:o=Ee()}=r,a=it(t);r.view_session_id=o,r.video_id=a,t.metadata=r,M.set(e,{});let c=Ie(t,e);Re(t,e,c),we(t,e,c),K(e);let i=ae(t,e,c),p=se(t,e,c);return{engine:c,setAutoplay:i,setPreload:p}},Ae=(t,e)=>{let n=e==null?void 0:e.engine;n&&(n.detachMedia(),n.destroy()),t!=null&&t.mux&&!t.mux.deleted&&(t.mux.destroy(),delete t.mux),t&&(t.removeAttribute("src"),t.load(),t.removeEventListener("error",_e),t.removeEventListener("error",$),t.removeEventListener("durationchange",He),M.delete(t),t.dispatchEvent(new Event("teardown")))};function De(t,e){var u;let n=S(t);if(!(n===b.M3U8))return!0;let o=!n||((u=e.canPlayType(n))!=null?u:!0),{preferPlayback:a}=t,c=a===R.MSE,i=a===R.NATIVE;return o&&(i||!(ke&&(c||nt)))}var Ie=(t,e)=>{let{debug:n,streamType:r,startTime:o=-1,metadata:a,preferCmcd:c,_hlsConfig:i={}}=t,u=S(t)===b.M3U8,d=De(t,e);if(u&&!d&&ke){let s={backBufferLength:30,renderTextTracksNatively:!1,liveDurationInfinity:!0,capLevelToPlayerSize:!0,capLevelOnFPSDrop:!0},l=Ne(r),f=c!==k.NONE?{useHeaders:c===k.HEADER,sessionId:a==null?void 0:a.view_session_id,contentId:a==null?void 0:a.video_id}:void 0;return new T({debug:n,startPosition:o,cmcd:f,xhrSetup:(_,L)=>{var j,Q;if(c&&c!==k.QUERY)return;let P=new URL(L);if(!P.searchParams.has("CMCD"))return;let Oe=((Q=(j=P.searchParams.get("CMCD"))==null?void 0:j.split(","))!=null?Q:[]).filter(J=>J.startsWith("sid")||J.startsWith("cid")).join(",");P.searchParams.set("CMCD",Oe),_.open("GET",P)},...s,...l,...i})}},Ne=t=>t===m.LIVE?{backBufferLength:8}:{},G=({playbackId:t,src:e,customDomain:n})=>{if(t)return!0;if(typeof e!="string")return!1;let r=window==null?void 0:window.location.href,o=new URL(e,r).hostname.toLocaleLowerCase();return o.includes(Pe)||!!n&&o.includes(n.toLocaleLowerCase())},Re=(t,e,n)=>{var a;let{envKey:r}=t,o=G(t);if(r||o){let{playerInitTime:c,playerSoftwareName:i,playerSoftwareVersion:p,beaconCollectionDomain:u,debug:d,disableCookies:s}=t,l={...t.metadata,video_title:((a=t==null?void 0:t.metadata)==null?void 0:a.video_title)||void 0},f=y=>typeof y.player_error_code=="string"?!1:typeof t.errorTranslator=="function"?t.errorTranslator(y):y;D.default.monitor(e,{debug:d,beaconCollectionDomain:u,hlsjs:n,Hls:n?T:void 0,automaticErrorTracking:!1,errorTranslator:f,disableCookies:s,data:{...r?{env_key:r}:{},player_software_name:i,player_software:i,player_software_version:p,player_init_time:c,...l}})}},we=(t,e,n)=>{var u;let r=De(t,e),{src:o}=t,a=d=>{e.ended||!Ce(e,n)||(X(e,n)?e.currentTime=e.buffered.end(e.buffered.length-1):e.dispatchEvent(new Event("ended")))},c,i,p=()=>{var l,f;let d=(l=H(e))==null?void 0:l.start(0),s=(f=H(e))==null?void 0:f.end(0);(i!==s||c!==d)&&e.dispatchEvent(new CustomEvent("seekablechange",{composed:!0})),c=d,i=s};if(e&&r){let d=S(t);if(typeof o=="string"){let s=()=>{if(q(e)!==m.LIVE||Number.isFinite(e.duration))return;let l=setInterval(p,1e3);e.addEventListener("teardown",()=>{clearInterval(l)},{once:!0}),g(e,"durationchange",()=>{Number.isFinite(e.duration)&&clearInterval(l)})};e.preload==="none"?g(e,"loadstart",()=>{Y(o,e,d).then(s)}):Y(o,e,d).then(s),e.setAttribute("src",o),t.startTime&&(((u=M.get(e))!=null?u:{}).startTime=t.startTime,e.addEventListener("durationchange",He,{once:!0}))}else e.removeAttribute("src");e.addEventListener("error",_e),e.addEventListener("error",$),e.addEventListener("emptied",()=>{e.querySelectorAll("track[data-removeondestroy]").forEach(l=>{l.remove()})},{once:!0}),g(e,"pause",a),g(e,"seeked",a),g(e,"play",()=>{e.ended||he(e.currentTime,e.duration)&&(e.currentTime=e.seekable.start(0))})}else n&&o?(n.once(T.Events.LEVEL_LOADED,(d,s)=>{Le(s.details,e,n),p(),q(e)===m.LIVE&&!Number.isFinite(e.duration)&&(n.on(T.Events.LEVEL_UPDATED,p),g(e,"durationchange",()=>{Number.isFinite(e.duration)&&n.off(T.Events.LEVELS_UPDATED,p)}))}),n.on(T.Events.ERROR,(d,s)=>{let l={[T.ErrorTypes.NETWORK_ERROR]:x.MEDIA_ERR_NETWORK,[T.ErrorTypes.MEDIA_ERROR]:x.MEDIA_ERR_DECODE},f=new x("",l[s.type]);f.fatal=s.fatal,f.data=s,e.dispatchEvent(new CustomEvent("error",{detail:f}))}),e.addEventListener("error",$),g(e,"waiting",a),ie(t,n),ce(e,n),n.attachMedia(e)):console.error("It looks like the video you're trying to play will not work on this system! If possible, try upgrading to the newest versions of your browser or software.")};function He(t){var r;let e=t.target,n=(r=M.get(e))==null?void 0:r.startTime;if(n&&ne(e.seekable,e.duration,n)){let o=e.preload==="auto";o&&(e.preload="none"),e.currentTime=n,o&&(e.preload="auto")}}async function _e(t){if(!t.isTrusted)return;t.stopImmediatePropagation();let e=t.target;if(!(e!=null&&e.error))return;let{message:n,code:r}=e.error,o=new x(n,r);if(e.src&&(r!==x.MEDIA_ERR_DECODE||r!==void 0))try{let{status:a}=await fetch(e.src);o.data={response:{code:a}}}catch{}e.dispatchEvent(new CustomEvent("error",{detail:o}))}function $(t){var r,o;if(!(t instanceof CustomEvent)||!(t.detail instanceof x))return;let e=t.target,n=t.detail;!n||!n.fatal||(((r=M.get(e))!=null?r:{}).error=n,(o=e.mux)==null||o.emit("error",{player_error_code:n.code,player_error_message:n.message,player_error_context:n.context}))} | ||
//# sourceMappingURL=index.cjs.js.map |
@@ -46,3 +46,3 @@ { | ||
"src/autoplay.ts": { | ||
"bytes": 4533, | ||
"bytes": 5113, | ||
"imports": [ | ||
@@ -127,3 +127,3 @@ { | ||
"src/index.ts": { | ||
"bytes": 30875, | ||
"bytes": 33464, | ||
"imports": [ | ||
@@ -194,3 +194,3 @@ { | ||
"inputs": {}, | ||
"bytes": 1931486 | ||
"bytes": 1935958 | ||
}, | ||
@@ -257,3 +257,3 @@ "dist/playback-core.mjs": { | ||
"src/index.ts": { | ||
"bytesInOutput": 9695 | ||
"bytesInOutput": 10311 | ||
}, | ||
@@ -276,3 +276,3 @@ "../../node_modules/hls.js/dist/hls.mjs": { | ||
"src/autoplay.ts": { | ||
"bytesInOutput": 910 | ||
"bytesInOutput": 1074 | ||
}, | ||
@@ -292,5 +292,5 @@ "src/preload.ts": { | ||
}, | ||
"bytes": 464424 | ||
"bytes": 465204 | ||
} | ||
} | ||
} |
@@ -1,6 +0,4 @@ | ||
import { Autoplay, PlaybackEngine } from './types'; | ||
import { Autoplay, PlaybackEngine, MuxMediaPropsInternal } from './types'; | ||
export declare const isAutoplayValue: (value: unknown) => value is Autoplay; | ||
export declare const setupAutoplay: ({ autoplay: maybeAutoplay }: { | ||
autoplay?: Autoplay; | ||
}, mediaEl: HTMLMediaElement, hls?: PlaybackEngine) => (newAutoplay?: Autoplay) => void; | ||
export declare const setupAutoplay: (props: Partial<MuxMediaPropsInternal>, mediaEl: HTMLMediaElement, hls?: PlaybackEngine) => (newAutoplay?: Autoplay) => void; | ||
export declare const handleAutoplay: (mediaEl: HTMLMediaElement, autoplay: Autoplay) => void; |
@@ -1,6 +0,4 @@ | ||
import { Autoplay, PlaybackEngine } from './types'; | ||
import { Autoplay, PlaybackEngine, MuxMediaPropsInternal } from './types'; | ||
export declare const isAutoplayValue: (value: unknown) => value is Autoplay; | ||
export declare const setupAutoplay: ({ autoplay: maybeAutoplay }: { | ||
autoplay?: Autoplay; | ||
}, mediaEl: HTMLMediaElement, hls?: PlaybackEngine) => (newAutoplay?: Autoplay) => void; | ||
export declare const setupAutoplay: (props: Partial<MuxMediaPropsInternal>, mediaEl: HTMLMediaElement, hls?: PlaybackEngine) => (newAutoplay?: Autoplay) => void; | ||
export declare const handleAutoplay: (mediaEl: HTMLMediaElement, autoplay: Autoplay) => void; |
{ | ||
"name": "@mux/playback-core", | ||
"version": "0.22.2-canary.0-a3662c7", | ||
"version": "0.22.2-canary.0-e54dcdb", | ||
"description": "Core library for media playback in the browser shared by mux elements", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.cjs.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
5187684
6540