@mux/playback-core
Advanced tools
Comparing version 0.22.4-canary.0-3abdbb8 to 0.22.4-canary.0-a6a76b6
@@ -20,3 +20,3 @@ { | ||
"src/types.ts": { | ||
"bytes": 5311, | ||
"bytes": 5368, | ||
"imports": [], | ||
@@ -117,3 +117,3 @@ "format": "esm" | ||
"src/index.ts": { | ||
"bytes": 33959, | ||
"bytes": 34043, | ||
"imports": [ | ||
@@ -184,3 +184,3 @@ { | ||
"inputs": {}, | ||
"bytes": 101539 | ||
"bytes": 101714 | ||
}, | ||
@@ -204,3 +204,3 @@ "dist/index.cjs.js": { | ||
"src/index.ts": { | ||
"bytesInOutput": 11477 | ||
"bytesInOutput": 11502 | ||
}, | ||
@@ -235,5 +235,5 @@ "src/hls.ts": { | ||
}, | ||
"bytes": 21261 | ||
"bytes": 21286 | ||
} | ||
} | ||
} |
@@ -20,3 +20,3 @@ { | ||
"src/types.ts": { | ||
"bytes": 5311, | ||
"bytes": 5368, | ||
"imports": [], | ||
@@ -117,3 +117,3 @@ "format": "esm" | ||
"src/index.ts": { | ||
"bytes": 33959, | ||
"bytes": 34043, | ||
"imports": [ | ||
@@ -184,3 +184,3 @@ { | ||
"inputs": {}, | ||
"bytes": 99851 | ||
"bytes": 100026 | ||
}, | ||
@@ -255,3 +255,3 @@ "dist/index.mjs": { | ||
"src/index.ts": { | ||
"bytesInOutput": 10270 | ||
"bytesInOutput": 10295 | ||
}, | ||
@@ -286,5 +286,5 @@ "src/hls.ts": { | ||
}, | ||
"bytes": 20548 | ||
"bytes": 20573 | ||
} | ||
} | ||
} |
{ | ||
"inputs": { | ||
"../../node_modules/mux-embed/dist/mux.js": { | ||
"bytes": 86018, | ||
"../../node_modules/mux-embed/dist/mux.mjs": { | ||
"bytes": 87160, | ||
"imports": [], | ||
"format": "cjs" | ||
"format": "esm" | ||
}, | ||
"../../node_modules/hls.js/dist/hls.mjs": { | ||
"bytes": 890477, | ||
"bytes": 993125, | ||
"imports": [], | ||
@@ -30,3 +30,3 @@ "format": "esm" | ||
"src/types.ts": { | ||
"bytes": 5311, | ||
"bytes": 5368, | ||
"imports": [], | ||
@@ -127,6 +127,6 @@ "format": "esm" | ||
"src/index.ts": { | ||
"bytes": 33959, | ||
"bytes": 34043, | ||
"imports": [ | ||
{ | ||
"path": "../../node_modules/mux-embed/dist/mux.js", | ||
"path": "../../node_modules/mux-embed/dist/mux.mjs", | ||
"kind": "import-statement", | ||
@@ -194,3 +194,3 @@ "original": "mux-embed" | ||
"inputs": {}, | ||
"bytes": 1936537 | ||
"bytes": 2125410 | ||
}, | ||
@@ -202,13 +202,10 @@ "dist/playback-core.js": { | ||
"inputs": { | ||
"../../node_modules/mux-embed/dist/mux.js": { | ||
"bytesInOutput": 86201 | ||
"../../node_modules/mux-embed/dist/mux.mjs": { | ||
"bytesInOutput": 86630 | ||
}, | ||
"src/index.ts": { | ||
"bytesInOutput": 10370 | ||
}, | ||
"../../node_modules/hls.js/dist/hls.mjs": { | ||
"bytesInOutput": 357422 | ||
"bytesInOutput": 392606 | ||
}, | ||
"src/hls.ts": { | ||
"bytesInOutput": 10 | ||
"bytesInOutput": 9 | ||
}, | ||
@@ -225,3 +222,3 @@ "src/errors.ts": { | ||
"src/autoplay.ts": { | ||
"bytesInOutput": 1074 | ||
"bytesInOutput": 1072 | ||
}, | ||
@@ -232,14 +229,17 @@ "src/preload.ts": { | ||
"src/media-tracks.ts": { | ||
"bytesInOutput": 1472 | ||
"bytesInOutput": 1465 | ||
}, | ||
"src/text-tracks.ts": { | ||
"bytesInOutput": 3579 | ||
"bytesInOutput": 3574 | ||
}, | ||
"src/pdt.ts": { | ||
"bytesInOutput": 360 | ||
}, | ||
"src/index.ts": { | ||
"bytesInOutput": 10346 | ||
} | ||
}, | ||
"bytes": 464138 | ||
"bytes": 499091 | ||
} | ||
} | ||
} |
@@ -1,4 +0,4 @@ | ||
"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:()=>g,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"},g={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 m=(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"?g.ON_DEMAND:g.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||m(e,"playing",()=>{o=!0},{once:!0})};if(i(),m(e,"loadstart",()=>{o=!1,i(),U(e,c)},{once:!0}),m(e,"loadstart",()=>{n||(t.streamType&&t.streamType!==g.UNKNOWN?a=t.streamType===g.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!==g.UNKNOWN?a=t.streamType===g.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&&m(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 m(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=>{m(t,"loadstart",async()=>{let r=await W(t,[],e);m(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(` | ||
"use strict";var Ve=Object.create;var N=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)N(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&&N(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?N(n,"default",{value:t,enumerable:!0}):n,t)),Ye=t=>Z(N({},"__esModule",{value:!0}),t);var ft={};Ke(ft,{AutoplayTypes:()=>h,CmcdTypeValues:()=>$e,CmcdTypes:()=>E,ExtensionMimeTypeMap:()=>v,Hls:()=>T,MaxResolution:()=>Ge,MediaError:()=>x,MimeTypeShorthandMap:()=>S,MinResolution:()=>je,PlaybackTypes:()=>w,RenditionOrder:()=>Qe,StreamTypes:()=>m,addCuePoints:()=>W,addTextTrack:()=>H,allMediaTypes:()=>Xe,generatePlayerInitTime:()=>rt,generateUUID:()=>Ee,getActiveCuePoint:()=>B,getCuePoints:()=>le,getCuePointsTrack:()=>D,getCurrentPdt:()=>fe,getEnded:()=>Ce,getError:()=>ct,getLiveEdgeStart:()=>dt,getMediaPlaylistLinesFromMultivariantPlaylistSrc:()=>Me,getSeekable:()=>_,getStartDate:()=>pe,getStreamInfoFromHlsjsLevelDetails:()=>xe,getStreamInfoFromPlaylistLines:()=>be,getStreamInfoFromSrcAndType:()=>ve,getStreamType:()=>q,getStreamTypeConfig:()=>Ne,getTargetLiveWindow:()=>ut,initialize:()=>pt,isKeyOf:()=>R,isMuxVideoSrc:()=>G,isPseudoEnded:()=>Se,isStuckOnLastFragment:()=>X,loadMedia:()=>we,mux:()=>I.default,muxMediaState:()=>g,removeTextTrack:()=>ue,setupCuePoints:()=>K,setupHls:()=>Ie,setupMux:()=>Re,shorthandKeys:()=>ze,teardown:()=>Ae,toMuxVideoURL:()=>ot,updateStreamInfoFromHlsjsLevelDetails:()=>Le,updateStreamInfoFromSrc:()=>Y});module.exports=Ye(ft);var I=ee(require("mux-embed"));var te=ee(require("hls.js")),T=te.default;var b=class b extends Error{constructor(n,r=b.MEDIA_ERR_CUSTOM,o,a){var s;super(n);this.name="MediaError",this.code=r,this.context=a,this.fatal=o!=null?o:r>=b.MEDIA_ERR_NETWORK&&r<=b.MEDIA_ERR_ENCRYPTED,this.message||(this.message=(s=b.defaultMessages[this.code])!=null?s:"")}};b.MEDIA_ERR_ABORTED=1,b.MEDIA_ERR_NETWORK=2,b.MEDIA_ERR_DECODE=3,b.MEDIA_ERR_SRC_NOT_SUPPORTED=4,b.MEDIA_ERR_ENCRYPTED=5,b.MEDIA_ERR_CUSTOM=100,b.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=b;var qe=t=>t==null,R=(t,e)=>qe(e)?!1:t in e,h={ANY:"any",MUTED:"muted"},m={ON_DEMAND:"on-demand",LIVE:"live",UNKNOWN:"unknown"},w={MSE:"mse",NATIVE:"native"},E={HEADER:"header",QUERY:"query",NONE:"none"},$e=Object.values(E),v={M3U8:"application/vnd.apple.mpegurl",MP4:"video/mp4"},S={HLS:v.M3U8},ze=Object.keys(S),Xe=[...Object.values(v),"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 y=(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]},C=t=>{let e=t.type;if(e){let r=e.toUpperCase();return R(r,S)?S[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 R(o,v)?v[o]:""};var Ze=Object.values(h),oe=t=>typeof t=="boolean"||typeof t=="string"&&Ze.includes(t),ae=(t,e,n)=>{let{autoplay:r}=t,o=!1,a=!1,s=oe(r)?r:!!r,c=()=>{o||y(e,"playing",()=>{o=!0},{once:!0})};if(c(),y(e,"loadstart",()=>{o=!1,c(),U(e,s)},{once:!0}),y(e,"loadstart",()=>{n||(t.streamType&&t.streamType!==m.UNKNOWN?a=t.streamType===m.LIVE:a=!Number.isFinite(e.duration)),U(e,s)},{once:!0}),n&&n.once(T.Events.LEVEL_LOADED,(u,d)=>{var i;t.streamType&&t.streamType!==m.UNKNOWN?a=t.streamType===m.LIVE:a=(i=d.details.live)!=null?i:!1}),!s){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&&y(e,"play",()=>{e.preload==="metadata"?n.once(T.Events.LEVEL_UPDATED,u):u()},{once:!0})}return u=>{o||(s=oe(u)?u:!!u,U(e,s))}},U=(t,e)=>{if(!e)return;let n=t.muted,r=()=>t.muted=n;switch(e){case h.ANY:t.play().catch(()=>{t.muted=!0,t.play().catch(r)});break;case h.MUTED:t.muted=!0,t.play().catch(r);break;default:t.play().catch(()=>{});break}};var se=({preload:t,src:e},n,r)=>{let o=i=>{i!=null&&["","none","metadata","auto"].includes(i)?n.setAttribute("preload",i):n.removeAttribute("preload")};if(!r)return o(t),o;let a=!1,s=!1,c=r.config.maxBufferLength,l=r.config.maxBufferSize,u=i=>{o(i);let p=i!=null?i:n.preload;s||p==="none"||(p==="metadata"?(r.config.maxBufferLength=1,r.config.maxBufferSize=1):(r.config.maxBufferLength=c,r.config.maxBufferSize=l),d())},d=()=>{!a&&e&&(a=!0,r.loadSource(e))};return y(n,"play",()=>{s=!0,r.config.maxBufferLength=c,r.config.maxBufferSize=l,d()},{once:!0}),u(t),u};function ie(t,e){var l;if(!("videoTracks"in t))return;let n=new WeakMap;e.on(T.Events.MANIFEST_PARSED,function(u,d){c();let i=t.addVideoTrack("main");i.selected=!0;for(let[p,f]of d.levels.entries()){let M=i.addRendition(f.url[0],f.width,f.height,f.videoCodec,f.bitrate);n.set(f,`${p}`),M.id=`${p}`}}),e.on(T.Events.AUDIO_TRACKS_UPDATED,function(u,d){s();for(let i of d.audioTracks){let p=i.default?"main":"alternative",f=t.addAudioTrack(p,i.name,i.lang);f.id=`${i.id}`,i.default&&(f.enabled=!0)}}),t.audioTracks.addEventListener("change",()=>{var i;let u=+((i=[...t.audioTracks].find(p=>p.enabled))==null?void 0:i.id),d=e.audioTracks.map(p=>p.id);u!=e.audioTrack&&d.includes(u)&&(e.audioTrack=u)}),e.on(T.Events.LEVELS_UPDATED,function(u,d){var f;let i=t.videoTracks[(f=t.videoTracks.selectedIndex)!=null?f:0];if(!i)return;let p=d.levels.map(M=>n.get(M));for(let M of t.videoRenditions)M.id&&!p.includes(M.id)&&i.removeRendition(M)});let r=u=>{let d=u.target.selectedIndex;d!=e.nextLevel&&o(d)},o=u=>{let d=t.currentTime,i=!1,p=(f,M)=>{i||(i=!Number.isFinite(M.endOffset))};e.on(T.Events.BUFFER_FLUSHING,p),e.nextLevel=u,e.off(T.Events.BUFFER_FLUSHING,p),i||e.trigger(T.Events.BUFFER_FLUSHING,{startOffset:d+10,endOffset:1/0,type:"video"})};(l=t.videoRenditions)==null||l.addEventListener("change",r);let a=()=>{for(let u of t.videoTracks)t.removeVideoTrack(u)},s=()=>{for(let u of t.audioTracks)t.removeAudioTrack(u)},c=()=>{a(),s()};e.once(T.Events.DESTROYING,c)}function ce(t,e){e.on(T.Events.NON_NATIVE_TEXT_TRACKS_FOUND,(o,{tracks:a})=>{a.forEach(s=>{var u;let c=(u=s.subtitleTrack)!=null?u:s.closedCaptions,l=e.subtitleTracks.findIndex(({lang:d,name:i,type:p})=>d==(c==null?void 0:c.lang)&&i===s.label&&p.toLowerCase()===s.kind);H(t,s.kind,s.label,c==null?void 0:c.lang,`${s.kind}${l}`)})});let n=()=>{var s;if(!e.subtitleTracks.length)return;let o=Array.from(t.textTracks).find(c=>c.id&&c.mode==="showing"&&["subtitles","captions"].includes(c.kind)),a=`${(s=e.subtitleTracks[e.subtitleTrack])==null?void 0:s.type.toLowerCase()}${e.subtitleTrack}`;if(o&&(e.subtitleTrack<0||(o==null?void 0:o.id)!==a)){let c=e.subtitleTracks.findIndex(({lang:l,name:u,type:d})=>l==o.language&&u===o.label&&d.toLowerCase()===o.kind);e.subtitleTrack=c}o&&(o==null?void 0:o.id)===a&&o.cues&&Array.from(o.cues).forEach(c=>{o.addCue(c)})};t.textTracks.addEventListener("change",n),e.on(T.Events.CUES_PARSED,(o,{track:a,cues:s})=>{let c=t.textTracks.getTrackById(a);if(!c)return;let l=c.mode==="disabled";l&&(c.mode="hidden"),s.forEach(u=>{var d;(d=c.cues)!=null&&d.getCueById(u.id)||c.addCue(u)}),l&&(c.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,s;if(!["subtitles","caption"].includes(o.kind)&&o.label==="thumbnails"){if(!((a=o.cues)!=null&&a.length)){let c=t.querySelector('track[label="thumbnails"]'),l=(s=c==null?void 0:c.getAttribute("src"))!=null?s:"";c==null||c.removeAttribute("src"),setTimeout(()=>{c==null||c.setAttribute("src",l)},0)}o.mode!=="hidden"&&(o.mode="hidden")}})};e.once(T.Events.MANIFEST_LOADED,r),e.once(T.Events.MEDIA_ATTACHED,r)}function H(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 A="cuepoints",F=Object.freeze({label:A}),D=(t,{label:e=A}=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=D(t,n);if(!r){let{label:o=A}=n;r=H(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 i,p;let s=Array.prototype.findIndex.call(r==null?void 0:r.cues,f=>f.startTime>=o),c=(i=r==null?void 0:r.cues)==null?void 0:i[s],l=c?c.startTime:Number.isFinite(t.duration)?t.duration:Number.MAX_SAFE_INTEGER,u=(p=r==null?void 0:r.cues)==null?void 0:p[s-1];u&&(u.endTime=o);let d=new VTTCue(o,l,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:A}){let n=D(t,e);return n!=null&&n.cues?Array.from(n.cues,r=>de(r)):[]}function B(t,e={label:A}){var a,s;let n=D(t,e);if(!((a=n==null?void 0:n.activeCues)!=null&&a.length))return;let{currentTime:r}=t,o=Array.prototype.find.call((s=n.activeCues)!=null?s:[],({startTime:c,endTime:l})=>c<=r&&l>r);return de(o)}async function K(t,e=F){return new Promise(n=>{y(t,"loadstart",async()=>{let r=await W(t,[],e);y(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(` | ||
`))}),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===g.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:g.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===g.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===g.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||L<0||Number.isFinite(e.duration)?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:g.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===g.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(m(e,"durationchange",p),e&&r){let d=S(t);if(typeof o=="string"){let s=()=>{if(q(e)!==g.LIVE||Number.isFinite(e.duration))return;let l=setInterval(p,1e3);e.addEventListener("teardown",()=>{clearInterval(l)},{once:!0}),m(e,"durationchange",()=>{Number.isFinite(e.duration)&&clearInterval(l)})};e.preload==="none"?m(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}),m(e,"pause",a),m(e,"seeked",a),m(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)===g.LIVE&&!Number.isFinite(e.duration)&&(n.on(T.Events.LEVEL_UPDATED,p),m(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",$),m(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}))} | ||
`))}),be=t=>{var s,c,l;let n=(c=((s=t.find(u=>u.startsWith("#EXT-X-PLAYLIST-TYPE")))!=null?s:"").split(":")[1])==null?void 0:c.trim(),r=O(n),o=V(n),a;if(r===m.LIVE){let u=t.find(i=>i.startsWith("#EXT-X-PART-INF"));if(!!u)a=+u.split(":")[1].split("=")[1]*2;else{let i=t.find(M=>M.startsWith("#EXT-X-TARGETDURATION")),p=(l=i==null?void 0:i.split(":"))==null?void 0:l[1];a=+(p!=null?p:6)*3}}return{streamType:r,targetLiveWindow:o,liveEdgeStartOffset:a}},ve=async(t,e)=>{if(e===v.MP4)return{streamType:m.ON_DEMAND,targetLiveWindow:Number.NaN,liveEdgeStartOffset:void 0};if(e===v.M3U8){let n=await Me(t);return be(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=C({src:t}))=>{var s,c,l;let{streamType:r,targetLiveWindow:o,liveEdgeStartOffset:a}=await ve(t,n);((s=g.get(e))!=null?s:{}).liveEdgeStartOffset=a,((c=g.get(e))!=null?c:{}).targetLiveWindow=o,e.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0})),((l=g.get(e))!=null?l:{}).streamType=r,e.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}))},xe=t=>{var s;let e=t.type,n=O(e),r=V(e),o,a=!!((s=t.partList)!=null&&s.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 c,l,u,d,i,p,f,M;let{streamType:r,targetLiveWindow:o,liveEdgeStartOffset:a,lowLatency:s}=xe(t);if(r===m.LIVE){s?(n.config.backBufferLength=(c=n.userConfig.backBufferLength)!=null?c:4,n.config.maxFragLookUpTolerance=(l=n.userConfig.maxFragLookUpTolerance)!=null?l:.001,n.config.abrBandWidthUpFactor=(u=n.userConfig.abrBandWidthUpFactor)!=null?u:n.config.abrBandWidthFactor):n.config.backBufferLength=(d=n.userConfig.backBufferLength)!=null?d:8;let P=Object.freeze({get length(){return e.seekable.length},start(L){return e.seekable.start(L)},end(L){var k;return L>this.length||L<0||Number.isFinite(e.duration)?e.seekable.end(L):(k=n.liveSyncPosition)!=null?k:e.seekable.end(L)}});((i=g.get(e))!=null?i:{}).seekable=P}((p=g.get(e))!=null?p:{}).liveEdgeStartOffset=a,((f=g.get(e))!=null?f:{}).targetLiveWindow=o,e.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0})),((M=g.get(e))!=null?M:{}).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,g=new WeakMap,Pe="mux.com",me,ge,ke=(ge=(me=T).isSupported)==null?void 0:ge.call(me),nt=tt,rt=()=>I.default.utils.now(),Ee=I.default.utils.generateUUID,ot=({playbackId:t,customDomain:e=Pe,maxResolution:n,minResolution:r,renditionOrder:o,tokens:{playback:a}={},extraSourceParams:s={}}={})=>{if(!t)return;let[c,l=""]=re(t),u=new URL(`https://stream.${e}/${c}.m3u8${l}`);return a||u.searchParams.has("token")?(u.searchParams.forEach((d,i)=>{i!="token"&&u.searchParams.delete(i)}),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(s).forEach(([d,i])=>{i!=null&&u.searchParams.set(d,i)})),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=g.get(t))==null?void 0:e.error},q=t=>{var e,n;return(n=(e=g.get(t))==null?void 0:e.streamType)!=null?n:m.UNKNOWN},ut=t=>{var e,n;return(n=(e=g.get(t))==null?void 0:e.targetLiveWindow)!=null?n:Number.NaN},_=t=>{var e,n;return(n=(e=g.get(t))==null?void 0:e.seekable)!=null?n:t.seekable},dt=t=>{var r;let e=(r=g.get(t))==null?void 0:r.liveEdgeStartOffset;if(typeof e!="number")return Number.NaN;let n=_(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,i;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:(i=e.levels.find(p=>!!p.details))==null?void 0:i.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,s=t.buffered.start(t.buffered.length-1),c=t.buffered.end(t.buffered.length-1);return a>s&&a<c},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,g.set(e,{});let s=Ie(t,e);Re(t,e,s),we(t,e,s),K(e);let c=ae(t,e,s),l=se(t,e,s);return{engine:s,setAutoplay:c,setPreload:l}},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),g.delete(t),t.dispatchEvent(new Event("teardown")))};function De(t,e){var u;let n=C(t);if(!(n===v.M3U8))return!0;let o=!n||((u=e.canPlayType(n))!=null?u:!0),{preferPlayback:a}=t,s=a===w.MSE,c=a===w.NATIVE;return o&&(c||!(ke&&(s||nt)))}var Ie=(t,e)=>{let{debug:n,streamType:r,startTime:o=-1,metadata:a,preferCmcd:s,_hlsConfig:c={}}=t,u=C(t)===v.M3U8,d=De(t,e);if(u&&!d&&ke){let i={backBufferLength:30,renderTextTracksNatively:!1,liveDurationInfinity:!0,capLevelToPlayerSize:!0,capLevelOnFPSDrop:!0},p=Ne(r),f=s!==E.NONE?{useHeaders:s===E.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:(P,L)=>{var j,Q;if(s&&s!==E.QUERY)return;let k=new URL(L);if(!k.searchParams.has("CMCD"))return;let Oe=((Q=(j=k.searchParams.get("CMCD"))==null?void 0:j.split(","))!=null?Q:[]).filter(J=>J.startsWith("sid")||J.startsWith("cid")).join(",");k.searchParams.set("CMCD",Oe),P.open("GET",k)},...i,...p,...c})}},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 s;let{envKey:r,disableTracking:o}=t,a=G(t);if(!o&&(r||a)){let{playerInitTime:c,playerSoftwareName:l,playerSoftwareVersion:u,beaconCollectionDomain:d,debug:i,disableCookies:p}=t,f={...t.metadata,video_title:((s=t==null?void 0:t.metadata)==null?void 0:s.video_title)||void 0},M=P=>typeof P.player_error_code=="string"?!1:typeof t.errorTranslator=="function"?t.errorTranslator(P):P;I.default.monitor(e,{debug:i,beaconCollectionDomain:d,hlsjs:n,Hls:n?T:void 0,automaticErrorTracking:!1,errorTranslator:M,disableCookies:p,data:{...r?{env_key:r}:{},player_software_name:l,player_software:l,player_software_version:u,player_init_time:c,...f}})}},we=(t,e,n)=>{var u;let r=De(t,e),{src:o}=t,a=()=>{e.ended||!Ce(e,n)||(X(e,n)?e.currentTime=e.buffered.end(e.buffered.length-1):e.dispatchEvent(new Event("ended")))},s,c,l=()=>{var p,f;let d=(p=_(e))==null?void 0:p.start(0),i=(f=_(e))==null?void 0:f.end(0);(c!==i||s!==d)&&e.dispatchEvent(new CustomEvent("seekablechange",{composed:!0})),s=d,c=i};if(y(e,"durationchange",l),e&&r){let d=C(t);if(typeof o=="string"){let i=()=>{if(q(e)!==m.LIVE||Number.isFinite(e.duration))return;let p=setInterval(l,1e3);e.addEventListener("teardown",()=>{clearInterval(p)},{once:!0}),y(e,"durationchange",()=>{Number.isFinite(e.duration)&&clearInterval(p)})};e.preload==="none"?y(e,"loadstart",()=>{Y(o,e,d).then(i)}):Y(o,e,d).then(i),e.setAttribute("src",o),t.startTime&&(((u=g.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(p=>{p.remove()})},{once:!0}),y(e,"pause",a),y(e,"seeked",a),y(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,i)=>{Le(i.details,e,n),l(),q(e)===m.LIVE&&!Number.isFinite(e.duration)&&(n.on(T.Events.LEVEL_UPDATED,l),y(e,"durationchange",()=>{Number.isFinite(e.duration)&&n.off(T.Events.LEVELS_UPDATED,l)}))}),n.on(T.Events.ERROR,(d,i)=>{let p={[T.ErrorTypes.NETWORK_ERROR]:x.MEDIA_ERR_NETWORK,[T.ErrorTypes.MEDIA_ERROR]:x.MEDIA_ERR_DECODE},f=new x("",p[i.type]);f.fatal=i.fatal,f.data=i,e.dispatchEvent(new CustomEvent("error",{detail:f}))}),e.addEventListener("error",$),y(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=g.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=g.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 |
{ | ||
"inputs": { | ||
"../../node_modules/mux-embed/dist/mux.js": { | ||
"bytes": 86018, | ||
"../../node_modules/mux-embed/dist/mux.mjs": { | ||
"bytes": 87160, | ||
"imports": [], | ||
"format": "cjs" | ||
"format": "esm" | ||
}, | ||
"../../node_modules/hls.js/dist/hls.mjs": { | ||
"bytes": 890477, | ||
"bytes": 993125, | ||
"imports": [], | ||
@@ -30,3 +30,3 @@ "format": "esm" | ||
"src/types.ts": { | ||
"bytes": 5311, | ||
"bytes": 5368, | ||
"imports": [], | ||
@@ -127,6 +127,6 @@ "format": "esm" | ||
"src/index.ts": { | ||
"bytes": 33959, | ||
"bytes": 34043, | ||
"imports": [ | ||
{ | ||
"path": "../../node_modules/mux-embed/dist/mux.js", | ||
"path": "../../node_modules/mux-embed/dist/mux.mjs", | ||
"kind": "import-statement", | ||
@@ -194,3 +194,3 @@ "original": "mux-embed" | ||
"inputs": {}, | ||
"bytes": 1936537 | ||
"bytes": 2125409 | ||
}, | ||
@@ -253,13 +253,10 @@ "dist/playback-core.mjs": { | ||
"inputs": { | ||
"../../node_modules/mux-embed/dist/mux.js": { | ||
"bytesInOutput": 86201 | ||
"../../node_modules/mux-embed/dist/mux.mjs": { | ||
"bytesInOutput": 86630 | ||
}, | ||
"src/index.ts": { | ||
"bytesInOutput": 10370 | ||
}, | ||
"../../node_modules/hls.js/dist/hls.mjs": { | ||
"bytesInOutput": 357422 | ||
"bytesInOutput": 392606 | ||
}, | ||
"src/hls.ts": { | ||
"bytesInOutput": 10 | ||
"bytesInOutput": 9 | ||
}, | ||
@@ -276,3 +273,3 @@ "src/errors.ts": { | ||
"src/autoplay.ts": { | ||
"bytesInOutput": 1074 | ||
"bytesInOutput": 1072 | ||
}, | ||
@@ -283,14 +280,17 @@ "src/preload.ts": { | ||
"src/media-tracks.ts": { | ||
"bytesInOutput": 1472 | ||
"bytesInOutput": 1465 | ||
}, | ||
"src/text-tracks.ts": { | ||
"bytesInOutput": 3579 | ||
"bytesInOutput": 3574 | ||
}, | ||
"src/pdt.ts": { | ||
"bytesInOutput": 360 | ||
}, | ||
"src/index.ts": { | ||
"bytesInOutput": 10346 | ||
} | ||
}, | ||
"bytes": 465263 | ||
"bytes": 500181 | ||
} | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
/// <reference path="mux-embed.d.ts" /> | ||
/// <reference types="mux-embed/dist/types/mux-embed" /> | ||
import mux from 'mux-embed'; | ||
@@ -76,3 +76,3 @@ import Hls from './hls'; | ||
export declare const isMuxVideoSrc: ({ playbackId, src, customDomain, }: Partial<Pick<MuxMediaPropsInternal, 'playbackId' | 'src' | 'customDomain'>>) => boolean; | ||
export declare const setupMux: (props: Partial<Pick<MuxMediaPropsInternal, 'envKey' | 'playerInitTime' | 'beaconCollectionDomain' | 'errorTranslator' | 'metadata' | 'debug' | 'playerSoftwareName' | 'playerSoftwareVersion' | 'playbackId' | 'src' | 'customDomain' | 'disableCookies'>>, mediaEl: HTMLMediaElement, hlsjs?: HlsInterface) => void; | ||
export declare const setupMux: (props: Partial<Pick<MuxMediaPropsInternal, 'envKey' | 'playerInitTime' | 'beaconCollectionDomain' | 'errorTranslator' | 'metadata' | 'debug' | 'playerSoftwareName' | 'playerSoftwareVersion' | 'playbackId' | 'src' | 'customDomain' | 'disableCookies' | 'disableTracking'>>, mediaEl: HTMLMediaElement, hlsjs?: HlsInterface) => void; | ||
export declare const loadMedia: (props: Partial<Pick<MuxMediaProps, 'preferPlayback' | 'src' | 'type' | 'startTime' | 'streamType' | 'autoplay'>>, mediaEl: HTMLMediaElement, hls?: Pick<Hls, 'config' | 'on' | 'once' | 'off' | 'trigger' | 'startLoad' | 'stopLoad' | 'recoverMediaError' | 'destroy' | 'loadSource' | 'attachMedia' | 'liveSyncPosition' | 'subtitleTracks' | 'subtitleTrack' | 'userConfig' | 'audioTrack' | 'audioTracks' | 'autoLevelEnabled' | 'nextLevel' | 'levels' | 'currentLevel'>) => void; |
@@ -1,2 +0,2 @@ | ||
/// <reference path="mux-embed.d.ts" /> | ||
/// <reference types="mux-embed/dist/types/mux-embed" /> | ||
import { Options } from 'mux-embed'; | ||
@@ -96,2 +96,3 @@ import { MediaError } from './errors'; | ||
errorTranslator: Options['errorTranslator']; | ||
disableTracking: boolean; | ||
disableCookies: Options['disableCookies']; | ||
@@ -98,0 +99,0 @@ playbackId: string; |
@@ -1,2 +0,2 @@ | ||
/// <reference path="mux-embed.d.ts" /> | ||
/// <reference types="mux-embed/dist/types/mux-embed" /> | ||
import mux from 'mux-embed'; | ||
@@ -76,3 +76,3 @@ import Hls from './hls'; | ||
export declare const isMuxVideoSrc: ({ playbackId, src, customDomain, }: Partial<Pick<MuxMediaPropsInternal, 'playbackId' | 'src' | 'customDomain'>>) => boolean; | ||
export declare const setupMux: (props: Partial<Pick<MuxMediaPropsInternal, 'envKey' | 'playerInitTime' | 'beaconCollectionDomain' | 'errorTranslator' | 'metadata' | 'debug' | 'playerSoftwareName' | 'playerSoftwareVersion' | 'playbackId' | 'src' | 'customDomain' | 'disableCookies'>>, mediaEl: HTMLMediaElement, hlsjs?: HlsInterface) => void; | ||
export declare const setupMux: (props: Partial<Pick<MuxMediaPropsInternal, 'envKey' | 'playerInitTime' | 'beaconCollectionDomain' | 'errorTranslator' | 'metadata' | 'debug' | 'playerSoftwareName' | 'playerSoftwareVersion' | 'playbackId' | 'src' | 'customDomain' | 'disableCookies' | 'disableTracking'>>, mediaEl: HTMLMediaElement, hlsjs?: HlsInterface) => void; | ||
export declare const loadMedia: (props: Partial<Pick<MuxMediaProps, 'preferPlayback' | 'src' | 'type' | 'startTime' | 'streamType' | 'autoplay'>>, mediaEl: HTMLMediaElement, hls?: Pick<Hls, 'config' | 'on' | 'once' | 'off' | 'trigger' | 'startLoad' | 'stopLoad' | 'recoverMediaError' | 'destroy' | 'loadSource' | 'attachMedia' | 'liveSyncPosition' | 'subtitleTracks' | 'subtitleTrack' | 'userConfig' | 'audioTrack' | 'audioTracks' | 'autoLevelEnabled' | 'nextLevel' | 'levels' | 'currentLevel'>) => void; |
@@ -1,2 +0,2 @@ | ||
/// <reference path="mux-embed.d.ts" /> | ||
/// <reference types="mux-embed/dist/types/mux-embed" /> | ||
import type { Options } from 'mux-embed'; | ||
@@ -96,2 +96,3 @@ import type { MediaError } from './errors'; | ||
errorTranslator: Options['errorTranslator']; | ||
disableTracking: boolean; | ||
disableCookies: Options['disableCookies']; | ||
@@ -98,0 +99,0 @@ playbackId: string; |
{ | ||
"name": "@mux/playback-core", | ||
"version": "0.22.4-canary.0-3abdbb8", | ||
"version": "0.22.4-canary.0-a6a76b6", | ||
"description": "Core library for media playback in the browser shared by mux elements", | ||
@@ -62,7 +62,6 @@ "main": "./dist/index.cjs.js", | ||
"dependencies": { | ||
"hls.js": "~1.4.13", | ||
"mux-embed": "~4.30.0" | ||
"hls.js": "~1.5.8", | ||
"mux-embed": "~5.2.0" | ||
}, | ||
"devDependencies": { | ||
"@mux/test-esm-exports": "0.1.0", | ||
"@open-wc/testing": "^3.0.3", | ||
@@ -69,0 +68,0 @@ "@typescript-eslint/parser": "^5.48.0", |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5588197
11
38
5650
+ Addedhls.js@1.5.18(transitive)
+ Addedmux-embed@5.2.1(transitive)
- Removedhls.js@1.4.14(transitive)
- Removedmux-embed@4.30.0(transitive)
Updatedhls.js@~1.5.8
Updatedmux-embed@~5.2.0