@mux/playback-core
Advanced tools
Comparing version 0.23.1-canary.0-84392f1 to 0.23.1-canary.0-845493b
@@ -6,2 +6,14 @@ # Change Log | ||
# [0.24.0](https://github.com/muxinc/elements/compare/@mux/playback-core@0.23.1...@mux/playback-core@0.24.0) (2024-05-28) | ||
### Features | ||
* **mux-player, mux-player-react, mux-video, mux-video-react, mux-audio, mux-audio-react, playback-core:** pdt clipping ([#923](https://github.com/muxinc/elements/issues/923)) ([22e9b06](https://github.com/muxinc/elements/commit/22e9b06e2e0913a6c34ebea53f4bbeded969b5a4)) | ||
* **playback-core, mux-video, mux-player:** addChapters interface ([#909](https://github.com/muxinc/elements/issues/909)) ([84392f1](https://github.com/muxinc/elements/commit/84392f14ee429b63ce26326e84e80e93bbdc70db)) | ||
## [0.23.1](https://github.com/muxinc/elements/compare/@mux/playback-core@0.23.0...@mux/playback-core@0.23.1) (2024-05-03) | ||
@@ -8,0 +20,0 @@ |
@@ -20,3 +20,3 @@ { | ||
"src/types.ts": { | ||
"bytes": 5652, | ||
"bytes": 5706, | ||
"imports": [], | ||
@@ -117,3 +117,3 @@ "format": "esm" | ||
"src/index.ts": { | ||
"bytes": 35767, | ||
"bytes": 36067, | ||
"imports": [ | ||
@@ -184,3 +184,3 @@ { | ||
"inputs": {}, | ||
"bytes": 110104 | ||
"bytes": 110635 | ||
}, | ||
@@ -204,3 +204,3 @@ "dist/index.cjs.js": { | ||
"src/index.ts": { | ||
"bytesInOutput": 11754 | ||
"bytesInOutput": 11890 | ||
}, | ||
@@ -235,5 +235,5 @@ "src/hls.ts": { | ||
}, | ||
"bytes": 22797 | ||
"bytes": 22933 | ||
} | ||
} | ||
} |
@@ -20,3 +20,3 @@ { | ||
"src/types.ts": { | ||
"bytes": 5652, | ||
"bytes": 5706, | ||
"imports": [], | ||
@@ -117,3 +117,3 @@ "format": "esm" | ||
"src/index.ts": { | ||
"bytes": 35767, | ||
"bytes": 36067, | ||
"imports": [ | ||
@@ -184,3 +184,3 @@ { | ||
"inputs": {}, | ||
"bytes": 108306 | ||
"bytes": 108837 | ||
}, | ||
@@ -259,3 +259,3 @@ "dist/index.mjs": { | ||
"src/index.ts": { | ||
"bytesInOutput": 10455 | ||
"bytesInOutput": 10591 | ||
}, | ||
@@ -290,5 +290,5 @@ "src/hls.ts": { | ||
}, | ||
"bytes": 22075 | ||
"bytes": 22211 | ||
} | ||
} | ||
} |
@@ -30,3 +30,3 @@ { | ||
"src/types.ts": { | ||
"bytes": 5652, | ||
"bytes": 5706, | ||
"imports": [], | ||
@@ -127,3 +127,3 @@ "format": "esm" | ||
"src/index.ts": { | ||
"bytes": 35767, | ||
"bytes": 36067, | ||
"imports": [ | ||
@@ -194,3 +194,3 @@ { | ||
"inputs": {}, | ||
"bytes": 2133690 | ||
"bytes": 2134221 | ||
}, | ||
@@ -236,8 +236,8 @@ "dist/playback-core.js": { | ||
"src/index.ts": { | ||
"bytesInOutput": 10509 | ||
"bytesInOutput": 10645 | ||
} | ||
}, | ||
"bytes": 500529 | ||
"bytes": 500665 | ||
} | ||
} | ||
} |
@@ -1,4 +0,4 @@ | ||
"use strict";var $e=Object.create;var I=Object.defineProperty;var Xe=Object.getOwnPropertyDescriptor;var Ge=Object.getOwnPropertyNames;var je=Object.getPrototypeOf,Je=Object.prototype.hasOwnProperty;var Qe=(e,t)=>{for(var n in t)I(e,n,{get:t[n],enumerable:!0})},oe=(e,t,n,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Ge(t))!Je.call(e,r)&&r!==n&&I(e,r,{get:()=>t[r],enumerable:!(a=Xe(t,r))||a.enumerable});return e};var se=(e,t,n)=>(n=e!=null?$e(je(e)):{},oe(t||!e||!e.__esModule?I(n,"default",{value:e,enumerable:!0}):n,e)),Ze=e=>oe(I({},"__esModule",{value:!0}),e);var Lt={};Qe(Lt,{AutoplayTypes:()=>h,CmcdTypeValues:()=>tt,CmcdTypes:()=>C,ExtensionMimeTypeMap:()=>b,Hls:()=>T,MaxResolution:()=>at,MediaError:()=>x,MimeTypeShorthandMap:()=>S,MinResolution:()=>ot,PlaybackTypes:()=>R,RenditionOrder:()=>st,StreamTypes:()=>g,addChapters:()=>X,addCuePoints:()=>Y,addTextTrack:()=>_,allMediaTypes:()=>rt,generatePlayerInitTime:()=>pt,generateUUID:()=>He,getActiveChapter:()=>G,getActiveCuePoint:()=>q,getChapters:()=>be,getCuePoints:()=>Me,getCurrentPdt:()=>Le,getEnded:()=>Oe,getError:()=>gt,getLiveEdgeStart:()=>vt,getMediaPlaylistLinesFromMultivariantPlaylistSrc:()=>he,getSeekable:()=>V,getStartDate:()=>xe,getStreamInfoFromHlsjsLevelDetails:()=>De,getStreamInfoFromPlaylistLines:()=>Se,getStreamInfoFromSrcAndType:()=>Ae,getStreamType:()=>J,getStreamTypeConfig:()=>We,getTargetLiveWindow:()=>Mt,getTextTrack:()=>E,initialize:()=>xt,isKeyOf:()=>N,isMuxVideoSrc:()=>te,isPseudoEnded:()=>_e,isStuckOnLastFragment:()=>ee,loadMedia:()=>Ke,mux:()=>D.default,muxMediaState:()=>M,removeTextTrack:()=>ye,setupChapters:()=>j,setupCuePoints:()=>z,setupHls:()=>Fe,setupMux:()=>Be,shorthandKeys:()=>nt,teardown:()=>Ve,toMuxVideoURL:()=>ft,updateStreamInfoFromHlsjsLevelDetails:()=>Ie,updateStreamInfoFromSrc:()=>O});module.exports=Ze(Lt);var D=se(require("mux-embed"));var ie=se(require("hls.js")),T=ie.default;var v=class v extends Error{constructor(n,a=v.MEDIA_ERR_CUSTOM,r,o){var s;super(n);this.name="MediaError",this.code=a,this.context=o,this.fatal=r!=null?r:a>=v.MEDIA_ERR_NETWORK&&a<=v.MEDIA_ERR_ENCRYPTED,this.message||(this.message=(s=v.defaultMessages[this.code])!=null?s:"")}};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 et=e=>e==null,N=(e,t)=>et(t)?!1:e in t,h={ANY:"any",MUTED:"muted"},g={ON_DEMAND:"on-demand",LIVE:"live",UNKNOWN:"unknown"},R={MSE:"mse",NATIVE:"native"},C={HEADER:"header",QUERY:"query",NONE:"none"},tt=Object.values(C),b={M3U8:"application/vnd.apple.mpegurl",MP4:"video/mp4"},S={HLS:b.M3U8},nt=Object.keys(S),rt=[...Object.values(b),"hls","HLS"],at={upTo720p:"720p",upTo1080p:"1080p",upTo1440p:"1440p",upTo2160p:"2160p"},ot={noLessThan480p:"480p",noLessThan540p:"540p",noLessThan720p:"720p",noLessThan1080p:"1080p",noLessThan1440p:"1440p",noLessThan2160p:"2160p"},st={DESCENDING:"desc"};var y=(e,t,n,a,r=e)=>{r.addEventListener(t,n,a),e.addEventListener("teardown",()=>{r.removeEventListener(t,n)},{once:!0})};function ue(e,t,n){t&&n>t&&(n=t);for(let a=0;a<e.length;a++)if(e.start(a)<=n&&e.end(a)>=n)return!0;return!1}var ce=e=>{let t=e.indexOf("?");if(t<0)return[e];let n=e.slice(0,t),a=e.slice(t);return[n,a]},A=e=>{let t=e.type;if(t){let a=t.toUpperCase();return N(a,S)?S[a]:t}let{src:n}=e;return n?it(n):""},U=e=>e==="VOD"?g.ON_DEMAND:g.LIVE,F=e=>e==="EVENT"?Number.POSITIVE_INFINITY:e==="VOD"?Number.NaN:0,it=e=>{let t="";try{t=new URL(e).pathname}catch{console.error("invalid url")}let n=t.lastIndexOf(".");if(n<0)return"";let r=t.slice(n+1).toUpperCase();return N(r,b)?b[r]:""};var ut=Object.values(h),de=e=>typeof e=="boolean"||typeof e=="string"&&ut.includes(e),le=(e,t,n)=>{let{autoplay:a}=e,r=!1,o=!1,s=de(a)?a:!!a,i=()=>{r||y(t,"playing",()=>{r=!0},{once:!0})};if(i(),y(t,"loadstart",()=>{r=!1,i(),W(t,s)},{once:!0}),y(t,"loadstart",()=>{n||(e.streamType&&e.streamType!==g.UNKNOWN?o=e.streamType===g.LIVE:o=!Number.isFinite(t.duration)),W(t,s)},{once:!0}),n&&n.once(T.Events.LEVEL_LOADED,(c,d)=>{var u;e.streamType&&e.streamType!==g.UNKNOWN?o=e.streamType===g.LIVE:o=(u=d.details.live)!=null?u:!1}),!s){let c=()=>{!o||Number.isFinite(e.startTime)||(n!=null&&n.liveSyncPosition?t.currentTime=n.liveSyncPosition:Number.isFinite(t.seekable.end(0))&&(t.currentTime=t.seekable.end(0)))};n&&y(t,"play",()=>{t.preload==="metadata"?n.once(T.Events.LEVEL_UPDATED,c):c()},{once:!0})}return c=>{r||(s=de(c)?c:!!c,W(t,s))}},W=(e,t)=>{if(!t)return;let n=e.muted,a=()=>e.muted=n;switch(t){case h.ANY:e.play().catch(()=>{e.muted=!0,e.play().catch(a)});break;case h.MUTED:e.muted=!0,e.play().catch(a);break;default:e.play().catch(()=>{});break}};var pe=({preload:e,src:t},n,a)=>{let r=u=>{u!=null&&["","none","metadata","auto"].includes(u)?n.setAttribute("preload",u):n.removeAttribute("preload")};if(!a)return r(e),r;let o=!1,s=!1,i=a.config.maxBufferLength,l=a.config.maxBufferSize,c=u=>{r(u);let p=u!=null?u:n.preload;s||p==="none"||(p==="metadata"?(a.config.maxBufferLength=1,a.config.maxBufferSize=1):(a.config.maxBufferLength=i,a.config.maxBufferSize=l),d())},d=()=>{!o&&t&&(o=!0,a.loadSource(t))};return y(n,"play",()=>{s=!0,a.config.maxBufferLength=i,a.config.maxBufferSize=l,d()},{once:!0}),c(e),c};function fe(e,t){var l;if(!("videoTracks"in e))return;let n=new WeakMap;t.on(T.Events.MANIFEST_PARSED,function(c,d){i();let u=e.addVideoTrack("main");u.selected=!0;for(let[p,f]of d.levels.entries()){let m=u.addRendition(f.url[0],f.width,f.height,f.videoCodec,f.bitrate);n.set(f,`${p}`),m.id=`${p}`}}),t.on(T.Events.AUDIO_TRACKS_UPDATED,function(c,d){s();for(let u of d.audioTracks){let p=u.default?"main":"alternative",f=e.addAudioTrack(p,u.name,u.lang);f.id=`${u.id}`,u.default&&(f.enabled=!0)}}),e.audioTracks.addEventListener("change",()=>{var u;let c=+((u=[...e.audioTracks].find(p=>p.enabled))==null?void 0:u.id),d=t.audioTracks.map(p=>p.id);c!=t.audioTrack&&d.includes(c)&&(t.audioTrack=c)}),t.on(T.Events.LEVELS_UPDATED,function(c,d){var f;let u=e.videoTracks[(f=e.videoTracks.selectedIndex)!=null?f:0];if(!u)return;let p=d.levels.map(m=>n.get(m));for(let m of e.videoRenditions)m.id&&!p.includes(m.id)&&u.removeRendition(m)});let a=c=>{let d=c.target.selectedIndex;d!=t.nextLevel&&r(d)},r=c=>{let d=e.currentTime,u=!1,p=(f,m)=>{u||(u=!Number.isFinite(m.endOffset))};t.on(T.Events.BUFFER_FLUSHING,p),t.nextLevel=c,t.off(T.Events.BUFFER_FLUSHING,p),u||t.trigger(T.Events.BUFFER_FLUSHING,{startOffset:d+10,endOffset:1/0,type:"video"})};(l=e.videoRenditions)==null||l.addEventListener("change",a);let o=()=>{for(let c of e.videoTracks)e.removeVideoTrack(c)},s=()=>{for(let c of e.audioTracks)e.removeAudioTrack(c)},i=()=>{o(),s()};t.once(T.Events.DESTROYING,i)}var B=e=>"time"in e?e.time:e.startTime;function Te(e,t){t.on(T.Events.NON_NATIVE_TEXT_TRACKS_FOUND,(r,{tracks:o})=>{o.forEach(s=>{var c;let i=(c=s.subtitleTrack)!=null?c:s.closedCaptions,l=t.subtitleTracks.findIndex(({lang:d,name:u,type:p})=>d==(i==null?void 0:i.lang)&&u===s.label&&p.toLowerCase()===s.kind);_(e,s.kind,s.label,i==null?void 0:i.lang,`${s.kind}${l}`)})});let n=()=>{var s;if(!t.subtitleTracks.length)return;let r=Array.from(e.textTracks).find(i=>i.id&&i.mode==="showing"&&["subtitles","captions"].includes(i.kind)),o=`${(s=t.subtitleTracks[t.subtitleTrack])==null?void 0:s.type.toLowerCase()}${t.subtitleTrack}`;if(r&&(t.subtitleTrack<0||(r==null?void 0:r.id)!==o)){let i=t.subtitleTracks.findIndex(({lang:l,name:c,type:d})=>l==r.language&&c===r.label&&d.toLowerCase()===r.kind);t.subtitleTrack=i}r&&(r==null?void 0:r.id)===o&&r.cues&&Array.from(r.cues).forEach(i=>{r.addCue(i)})};e.textTracks.addEventListener("change",n),t.on(T.Events.CUES_PARSED,(r,{track:o,cues:s})=>{let i=e.textTracks.getTrackById(o);if(!i)return;let l=i.mode==="disabled";l&&(i.mode="hidden"),s.forEach(c=>{var d;(d=i.cues)!=null&&d.getCueById(c.id)||i.addCue(c)}),l&&(i.mode="disabled")}),t.once(T.Events.DESTROYING,()=>{e.textTracks.removeEventListener("change",n),e.querySelectorAll("track[data-removeondestroy]").forEach(o=>{o.remove()})});let a=()=>{Array.from(e.textTracks).forEach(r=>{var o,s;if(!["subtitles","caption"].includes(r.kind)&&r.label==="thumbnails"){if(!((o=r.cues)!=null&&o.length)){let i=e.querySelector('track[label="thumbnails"]'),l=(s=i==null?void 0:i.getAttribute("src"))!=null?s:"";i==null||i.removeAttribute("src"),setTimeout(()=>{i==null||i.setAttribute("src",l)},0)}r.mode!=="hidden"&&(r.mode="hidden")}})};t.once(T.Events.MANIFEST_LOADED,a),t.once(T.Events.MEDIA_ATTACHED,a)}function _(e,t,n,a,r){let o=document.createElement("track");return o.kind=t,o.label=n,a&&(o.srclang=a),r&&(o.id=r),o.track.mode=["subtitles","captions"].includes(t)?"disabled":"hidden",o.setAttribute("data-removeondestroy",""),e.append(o),o.track}function ye(e,t){let n=Array.prototype.find.call(e.querySelectorAll("track"),a=>a.track===t);n==null||n.remove()}function E(e,t,n){var a;return(a=Array.from(e.querySelectorAll("track")).find(r=>r.track.label===t&&r.track.kind===n))==null?void 0:a.track}async function me(e,t,n,a){let r=E(e,n,a);return r||(r=_(e,a,n),r.mode="hidden",await new Promise(o=>setTimeout(()=>o(void 0),0))),r.mode!=="hidden"&&(r.mode="hidden"),[...t].sort((o,s)=>B(s)-B(o)).forEach(o=>{var l,c;let s=o.value,i=B(o);if("endTime"in o&&o.endTime!=null)r==null||r.addCue(new VTTCue(i,o.endTime,a==="chapters"?s:JSON.stringify(s!=null?s:null)));else{let d=Array.prototype.findIndex.call(r==null?void 0:r.cues,m=>m.startTime>=i),u=(l=r==null?void 0:r.cues)==null?void 0:l[d],p=u?u.startTime:Number.isFinite(e.duration)?e.duration:Number.MAX_SAFE_INTEGER,f=(c=r==null?void 0:r.cues)==null?void 0:c[d-1];f&&(f.endTime=i),r==null||r.addCue(new VTTCue(i,p,a==="chapters"?s:JSON.stringify(s!=null?s:null)))}}),e.textTracks.dispatchEvent(new Event("change",{bubbles:!0,composed:!0})),r}var K="cuepoints",ge=Object.freeze({label:K});async function Y(e,t,n=ge){return me(e,t,n.label,"metadata")}var H=e=>({time:e.startTime,value:JSON.parse(e.text)});function Me(e,t={label:K}){let n=E(e,t.label,"metadata");return n!=null&&n.cues?Array.from(n.cues,a=>H(a)):[]}function q(e,t={label:K}){var o,s;let n=E(e,t.label,"metadata");if(!((o=n==null?void 0:n.activeCues)!=null&&o.length))return;if(n.activeCues.length===1)return H(n.activeCues[0]);let{currentTime:a}=e,r=Array.prototype.find.call((s=n.activeCues)!=null?s:[],({startTime:i,endTime:l})=>i<=a&&l>a);return H(r||n.activeCues[0])}async function z(e,t=ge){return new Promise(n=>{y(e,"loadstart",async()=>{let a=await Y(e,[],t);y(e,"cuechange",()=>{let r=q(e);if(r){let o=new CustomEvent("cuepointchange",{composed:!0,bubbles:!0,detail:r});e.dispatchEvent(o)}},{},a),n(a)})})}var $="chapters",ve=Object.freeze({label:$}),w=e=>({startTime:e.startTime,endTime:e.endTime,value:e.text});async function X(e,t,n=ve){return me(e,t,n.label,"chapters")}function be(e,t={label:$}){var a;let n=E(e,t.label,"chapters");return(a=n==null?void 0:n.cues)!=null&&a.length?Array.from(n.cues,r=>w(r)):[]}function G(e,t={label:$}){var o,s;let n=E(e,t.label,"chapters");if(!((o=n==null?void 0:n.activeCues)!=null&&o.length))return;if(n.activeCues.length===1)return w(n.activeCues[0]);let{currentTime:a}=e,r=Array.prototype.find.call((s=n.activeCues)!=null?s:[],({startTime:i,endTime:l})=>i<=a&&l>a);return w(r||n.activeCues[0])}async function j(e,t=ve){return new Promise(n=>{y(e,"loadstart",async()=>{let a=await X(e,[],t);y(e,"cuechange",()=>{let r=G(e);if(r){let o=new CustomEvent("chapterchange",{composed:!0,bubbles:!0,detail:r});e.dispatchEvent(o)}},{},a),n(a)})})}function xe(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 he=async e=>fetch(e).then(t=>t.text()).then(t=>{let n=t.split(` | ||
"use strict";var ze=Object.create;var I=Object.defineProperty;var Xe=Object.getOwnPropertyDescriptor;var Ge=Object.getOwnPropertyNames;var je=Object.getPrototypeOf,Je=Object.prototype.hasOwnProperty;var Qe=(e,t)=>{for(var n in t)I(e,n,{get:t[n],enumerable:!0})},oe=(e,t,n,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Ge(t))!Je.call(e,r)&&r!==n&&I(e,r,{get:()=>t[r],enumerable:!(a=Xe(t,r))||a.enumerable});return e};var se=(e,t,n)=>(n=e!=null?ze(je(e)):{},oe(t||!e||!e.__esModule?I(n,"default",{value:e,enumerable:!0}):n,e)),Ze=e=>oe(I({},"__esModule",{value:!0}),e);var Lt={};Qe(Lt,{AutoplayTypes:()=>C,CmcdTypeValues:()=>tt,CmcdTypes:()=>h,ExtensionMimeTypeMap:()=>b,Hls:()=>T,MaxResolution:()=>at,MediaError:()=>x,MimeTypeShorthandMap:()=>S,MinResolution:()=>ot,PlaybackTypes:()=>R,RenditionOrder:()=>st,StreamTypes:()=>g,addChapters:()=>X,addCuePoints:()=>Y,addTextTrack:()=>_,allMediaTypes:()=>rt,generatePlayerInitTime:()=>pt,generateUUID:()=>He,getActiveChapter:()=>G,getActiveCuePoint:()=>$,getChapters:()=>be,getCuePoints:()=>Me,getCurrentPdt:()=>Le,getEnded:()=>Oe,getError:()=>gt,getLiveEdgeStart:()=>vt,getMediaPlaylistLinesFromMultivariantPlaylistSrc:()=>Ce,getSeekable:()=>V,getStartDate:()=>xe,getStreamInfoFromHlsjsLevelDetails:()=>De,getStreamInfoFromPlaylistLines:()=>Se,getStreamInfoFromSrcAndType:()=>Ae,getStreamType:()=>J,getStreamTypeConfig:()=>We,getTargetLiveWindow:()=>Mt,getTextTrack:()=>E,initialize:()=>xt,isKeyOf:()=>N,isMuxVideoSrc:()=>te,isPseudoEnded:()=>_e,isStuckOnLastFragment:()=>ee,loadMedia:()=>Ke,mux:()=>D.default,muxMediaState:()=>M,removeTextTrack:()=>ye,setupChapters:()=>j,setupCuePoints:()=>q,setupHls:()=>Fe,setupMux:()=>Be,shorthandKeys:()=>nt,teardown:()=>Ve,toMuxVideoURL:()=>ft,updateStreamInfoFromHlsjsLevelDetails:()=>Ie,updateStreamInfoFromSrc:()=>O});module.exports=Ze(Lt);var D=se(require("mux-embed"));var ie=se(require("hls.js")),T=ie.default;var v=class v extends Error{constructor(n,a=v.MEDIA_ERR_CUSTOM,r,o){var s;super(n);this.name="MediaError",this.code=a,this.context=o,this.fatal=r!=null?r:a>=v.MEDIA_ERR_NETWORK&&a<=v.MEDIA_ERR_ENCRYPTED,this.message||(this.message=(s=v.defaultMessages[this.code])!=null?s:"")}};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 et=e=>e==null,N=(e,t)=>et(t)?!1:e in t,C={ANY:"any",MUTED:"muted"},g={ON_DEMAND:"on-demand",LIVE:"live",UNKNOWN:"unknown"},R={MSE:"mse",NATIVE:"native"},h={HEADER:"header",QUERY:"query",NONE:"none"},tt=Object.values(h),b={M3U8:"application/vnd.apple.mpegurl",MP4:"video/mp4"},S={HLS:b.M3U8},nt=Object.keys(S),rt=[...Object.values(b),"hls","HLS"],at={upTo720p:"720p",upTo1080p:"1080p",upTo1440p:"1440p",upTo2160p:"2160p"},ot={noLessThan480p:"480p",noLessThan540p:"540p",noLessThan720p:"720p",noLessThan1080p:"1080p",noLessThan1440p:"1440p",noLessThan2160p:"2160p"},st={DESCENDING:"desc"};var y=(e,t,n,a,r=e)=>{r.addEventListener(t,n,a),e.addEventListener("teardown",()=>{r.removeEventListener(t,n)},{once:!0})};function ue(e,t,n){t&&n>t&&(n=t);for(let a=0;a<e.length;a++)if(e.start(a)<=n&&e.end(a)>=n)return!0;return!1}var ce=e=>{let t=e.indexOf("?");if(t<0)return[e];let n=e.slice(0,t),a=e.slice(t);return[n,a]},A=e=>{let t=e.type;if(t){let a=t.toUpperCase();return N(a,S)?S[a]:t}let{src:n}=e;return n?it(n):""},U=e=>e==="VOD"?g.ON_DEMAND:g.LIVE,F=e=>e==="EVENT"?Number.POSITIVE_INFINITY:e==="VOD"?Number.NaN:0,it=e=>{let t="";try{t=new URL(e).pathname}catch{console.error("invalid url")}let n=t.lastIndexOf(".");if(n<0)return"";let r=t.slice(n+1).toUpperCase();return N(r,b)?b[r]:""};var ut=Object.values(C),de=e=>typeof e=="boolean"||typeof e=="string"&&ut.includes(e),le=(e,t,n)=>{let{autoplay:a}=e,r=!1,o=!1,s=de(a)?a:!!a,u=()=>{r||y(t,"playing",()=>{r=!0},{once:!0})};if(u(),y(t,"loadstart",()=>{r=!1,u(),W(t,s)},{once:!0}),y(t,"loadstart",()=>{n||(e.streamType&&e.streamType!==g.UNKNOWN?o=e.streamType===g.LIVE:o=!Number.isFinite(t.duration)),W(t,s)},{once:!0}),n&&n.once(T.Events.LEVEL_LOADED,(c,d)=>{var i;e.streamType&&e.streamType!==g.UNKNOWN?o=e.streamType===g.LIVE:o=(i=d.details.live)!=null?i:!1}),!s){let c=()=>{!o||Number.isFinite(e.startTime)||(n!=null&&n.liveSyncPosition?t.currentTime=n.liveSyncPosition:Number.isFinite(t.seekable.end(0))&&(t.currentTime=t.seekable.end(0)))};n&&y(t,"play",()=>{t.preload==="metadata"?n.once(T.Events.LEVEL_UPDATED,c):c()},{once:!0})}return c=>{r||(s=de(c)?c:!!c,W(t,s))}},W=(e,t)=>{if(!t)return;let n=e.muted,a=()=>e.muted=n;switch(t){case C.ANY:e.play().catch(()=>{e.muted=!0,e.play().catch(a)});break;case C.MUTED:e.muted=!0,e.play().catch(a);break;default:e.play().catch(()=>{});break}};var pe=({preload:e,src:t},n,a)=>{let r=i=>{i!=null&&["","none","metadata","auto"].includes(i)?n.setAttribute("preload",i):n.removeAttribute("preload")};if(!a)return r(e),r;let o=!1,s=!1,u=a.config.maxBufferLength,p=a.config.maxBufferSize,c=i=>{r(i);let l=i!=null?i:n.preload;s||l==="none"||(l==="metadata"?(a.config.maxBufferLength=1,a.config.maxBufferSize=1):(a.config.maxBufferLength=u,a.config.maxBufferSize=p),d())},d=()=>{!o&&t&&(o=!0,a.loadSource(t))};return y(n,"play",()=>{s=!0,a.config.maxBufferLength=u,a.config.maxBufferSize=p,d()},{once:!0}),c(e),c};function fe(e,t){var p;if(!("videoTracks"in e))return;let n=new WeakMap;t.on(T.Events.MANIFEST_PARSED,function(c,d){u();let i=e.addVideoTrack("main");i.selected=!0;for(let[l,f]of d.levels.entries()){let m=i.addRendition(f.url[0],f.width,f.height,f.videoCodec,f.bitrate);n.set(f,`${l}`),m.id=`${l}`}}),t.on(T.Events.AUDIO_TRACKS_UPDATED,function(c,d){s();for(let i of d.audioTracks){let l=i.default?"main":"alternative",f=e.addAudioTrack(l,i.name,i.lang);f.id=`${i.id}`,i.default&&(f.enabled=!0)}}),e.audioTracks.addEventListener("change",()=>{var i;let c=+((i=[...e.audioTracks].find(l=>l.enabled))==null?void 0:i.id),d=t.audioTracks.map(l=>l.id);c!=t.audioTrack&&d.includes(c)&&(t.audioTrack=c)}),t.on(T.Events.LEVELS_UPDATED,function(c,d){var f;let i=e.videoTracks[(f=e.videoTracks.selectedIndex)!=null?f:0];if(!i)return;let l=d.levels.map(m=>n.get(m));for(let m of e.videoRenditions)m.id&&!l.includes(m.id)&&i.removeRendition(m)});let a=c=>{let d=c.target.selectedIndex;d!=t.nextLevel&&r(d)},r=c=>{let d=e.currentTime,i=!1,l=(f,m)=>{i||(i=!Number.isFinite(m.endOffset))};t.on(T.Events.BUFFER_FLUSHING,l),t.nextLevel=c,t.off(T.Events.BUFFER_FLUSHING,l),i||t.trigger(T.Events.BUFFER_FLUSHING,{startOffset:d+10,endOffset:1/0,type:"video"})};(p=e.videoRenditions)==null||p.addEventListener("change",a);let o=()=>{for(let c of e.videoTracks)e.removeVideoTrack(c)},s=()=>{for(let c of e.audioTracks)e.removeAudioTrack(c)},u=()=>{o(),s()};t.once(T.Events.DESTROYING,u)}var B=e=>"time"in e?e.time:e.startTime;function Te(e,t){t.on(T.Events.NON_NATIVE_TEXT_TRACKS_FOUND,(r,{tracks:o})=>{o.forEach(s=>{var c;let u=(c=s.subtitleTrack)!=null?c:s.closedCaptions,p=t.subtitleTracks.findIndex(({lang:d,name:i,type:l})=>d==(u==null?void 0:u.lang)&&i===s.label&&l.toLowerCase()===s.kind);_(e,s.kind,s.label,u==null?void 0:u.lang,`${s.kind}${p}`)})});let n=()=>{var s;if(!t.subtitleTracks.length)return;let r=Array.from(e.textTracks).find(u=>u.id&&u.mode==="showing"&&["subtitles","captions"].includes(u.kind)),o=`${(s=t.subtitleTracks[t.subtitleTrack])==null?void 0:s.type.toLowerCase()}${t.subtitleTrack}`;if(r&&(t.subtitleTrack<0||(r==null?void 0:r.id)!==o)){let u=t.subtitleTracks.findIndex(({lang:p,name:c,type:d})=>p==r.language&&c===r.label&&d.toLowerCase()===r.kind);t.subtitleTrack=u}r&&(r==null?void 0:r.id)===o&&r.cues&&Array.from(r.cues).forEach(u=>{r.addCue(u)})};e.textTracks.addEventListener("change",n),t.on(T.Events.CUES_PARSED,(r,{track:o,cues:s})=>{let u=e.textTracks.getTrackById(o);if(!u)return;let p=u.mode==="disabled";p&&(u.mode="hidden"),s.forEach(c=>{var d;(d=u.cues)!=null&&d.getCueById(c.id)||u.addCue(c)}),p&&(u.mode="disabled")}),t.once(T.Events.DESTROYING,()=>{e.textTracks.removeEventListener("change",n),e.querySelectorAll("track[data-removeondestroy]").forEach(o=>{o.remove()})});let a=()=>{Array.from(e.textTracks).forEach(r=>{var o,s;if(!["subtitles","caption"].includes(r.kind)&&r.label==="thumbnails"){if(!((o=r.cues)!=null&&o.length)){let u=e.querySelector('track[label="thumbnails"]'),p=(s=u==null?void 0:u.getAttribute("src"))!=null?s:"";u==null||u.removeAttribute("src"),setTimeout(()=>{u==null||u.setAttribute("src",p)},0)}r.mode!=="hidden"&&(r.mode="hidden")}})};t.once(T.Events.MANIFEST_LOADED,a),t.once(T.Events.MEDIA_ATTACHED,a)}function _(e,t,n,a,r){let o=document.createElement("track");return o.kind=t,o.label=n,a&&(o.srclang=a),r&&(o.id=r),o.track.mode=["subtitles","captions"].includes(t)?"disabled":"hidden",o.setAttribute("data-removeondestroy",""),e.append(o),o.track}function ye(e,t){let n=Array.prototype.find.call(e.querySelectorAll("track"),a=>a.track===t);n==null||n.remove()}function E(e,t,n){var a;return(a=Array.from(e.querySelectorAll("track")).find(r=>r.track.label===t&&r.track.kind===n))==null?void 0:a.track}async function me(e,t,n,a){let r=E(e,n,a);return r||(r=_(e,a,n),r.mode="hidden",await new Promise(o=>setTimeout(()=>o(void 0),0))),r.mode!=="hidden"&&(r.mode="hidden"),[...t].sort((o,s)=>B(s)-B(o)).forEach(o=>{var p,c;let s=o.value,u=B(o);if("endTime"in o&&o.endTime!=null)r==null||r.addCue(new VTTCue(u,o.endTime,a==="chapters"?s:JSON.stringify(s!=null?s:null)));else{let d=Array.prototype.findIndex.call(r==null?void 0:r.cues,m=>m.startTime>=u),i=(p=r==null?void 0:r.cues)==null?void 0:p[d],l=i?i.startTime:Number.isFinite(e.duration)?e.duration:Number.MAX_SAFE_INTEGER,f=(c=r==null?void 0:r.cues)==null?void 0:c[d-1];f&&(f.endTime=u),r==null||r.addCue(new VTTCue(u,l,a==="chapters"?s:JSON.stringify(s!=null?s:null)))}}),e.textTracks.dispatchEvent(new Event("change",{bubbles:!0,composed:!0})),r}var K="cuepoints",ge=Object.freeze({label:K});async function Y(e,t,n=ge){return me(e,t,n.label,"metadata")}var H=e=>({time:e.startTime,value:JSON.parse(e.text)});function Me(e,t={label:K}){let n=E(e,t.label,"metadata");return n!=null&&n.cues?Array.from(n.cues,a=>H(a)):[]}function $(e,t={label:K}){var o,s;let n=E(e,t.label,"metadata");if(!((o=n==null?void 0:n.activeCues)!=null&&o.length))return;if(n.activeCues.length===1)return H(n.activeCues[0]);let{currentTime:a}=e,r=Array.prototype.find.call((s=n.activeCues)!=null?s:[],({startTime:u,endTime:p})=>u<=a&&p>a);return H(r||n.activeCues[0])}async function q(e,t=ge){return new Promise(n=>{y(e,"loadstart",async()=>{let a=await Y(e,[],t);y(e,"cuechange",()=>{let r=$(e);if(r){let o=new CustomEvent("cuepointchange",{composed:!0,bubbles:!0,detail:r});e.dispatchEvent(o)}},{},a),n(a)})})}var z="chapters",ve=Object.freeze({label:z}),w=e=>({startTime:e.startTime,endTime:e.endTime,value:e.text});async function X(e,t,n=ve){return me(e,t,n.label,"chapters")}function be(e,t={label:z}){var a;let n=E(e,t.label,"chapters");return(a=n==null?void 0:n.cues)!=null&&a.length?Array.from(n.cues,r=>w(r)):[]}function G(e,t={label:z}){var o,s;let n=E(e,t.label,"chapters");if(!((o=n==null?void 0:n.activeCues)!=null&&o.length))return;if(n.activeCues.length===1)return w(n.activeCues[0]);let{currentTime:a}=e,r=Array.prototype.find.call((s=n.activeCues)!=null?s:[],({startTime:u,endTime:p})=>u<=a&&p>a);return w(r||n.activeCues[0])}async function j(e,t=ve){return new Promise(n=>{y(e,"loadstart",async()=>{let a=await X(e,[],t);y(e,"cuechange",()=>{let r=G(e);if(r){let o=new CustomEvent("chapterchange",{composed:!0,bubbles:!0,detail:r});e.dispatchEvent(o)}},{},a),n(a)})})}function xe(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 Ce=async e=>fetch(e).then(t=>t.text()).then(t=>{let n=t.split(` | ||
`).find((a,r,o)=>r&&o[r-1].startsWith("#EXT-X-STREAM-INF"));return fetch(n).then(a=>a.text()).then(a=>a.split(` | ||
`))}),Se=e=>{var s,i,l;let n=(i=((s=e.find(c=>c.startsWith("#EXT-X-PLAYLIST-TYPE")))!=null?s:"").split(":")[1])==null?void 0:i.trim(),a=U(n),r=F(n),o;if(a===g.LIVE){let c=e.find(u=>u.startsWith("#EXT-X-PART-INF"));if(!!c)o=+c.split(":")[1].split("=")[1]*2;else{let u=e.find(m=>m.startsWith("#EXT-X-TARGETDURATION")),p=(l=u==null?void 0:u.split(":"))==null?void 0:l[1];o=+(p!=null?p:6)*3}}return{streamType:a,targetLiveWindow:r,liveEdgeStartOffset:o}},Ae=async(e,t)=>{if(t===b.MP4)return{streamType:g.ON_DEMAND,targetLiveWindow:Number.NaN,liveEdgeStartOffset:void 0};if(t===b.M3U8){let n=await he(e);return Se(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}},O=async(e,t,n=A({src:e}))=>{var s,i,l;let{streamType:a,targetLiveWindow:r,liveEdgeStartOffset:o}=await Ae(e,n);((s=M.get(t))!=null?s:{}).liveEdgeStartOffset=o,((i=M.get(t))!=null?i:{}).targetLiveWindow=r,t.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0})),((l=M.get(t))!=null?l:{}).streamType=a,t.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}))},De=e=>{var s;let t=e.type,n=U(t),a=F(t),r,o=!!((s=e.partList)!=null&&s.length);return n===g.LIVE&&(r=o?e.partTarget*2:e.targetduration*3),{streamType:n,targetLiveWindow:a,liveEdgeStartOffset:r,lowLatency:o}},Ie=(e,t,n)=>{var i,l,c,d,u,p,f,m;let{streamType:a,targetLiveWindow:r,liveEdgeStartOffset:o,lowLatency:s}=De(e);if(a===g.LIVE){s?(n.config.backBufferLength=(i=n.userConfig.backBufferLength)!=null?i:4,n.config.maxFragLookUpTolerance=(l=n.userConfig.maxFragLookUpTolerance)!=null?l:.001,n.config.abrBandWidthUpFactor=(c=n.userConfig.abrBandWidthUpFactor)!=null?c:n.config.abrBandWidthFactor):n.config.backBufferLength=(d=n.userConfig.backBufferLength)!=null?d:8;let k=Object.freeze({get length(){return t.seekable.length},start(L){return t.seekable.start(L)},end(L){var P;return L>this.length||L<0||Number.isFinite(t.duration)?t.seekable.end(L):(P=n.liveSyncPosition)!=null?P:t.seekable.end(L)}});((u=M.get(t))!=null?u:{}).seekable=k}((p=M.get(t))!=null?p:{}).liveEdgeStartOffset=o,((f=M.get(t))!=null?f:{}).targetLiveWindow=r,t.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0})),((m=M.get(t))!=null?m:{}).streamType=a,t.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}))},ke,Pe,ct=(Pe=(ke=globalThis==null?void 0:globalThis.navigator)==null?void 0:ke.userAgent)!=null?Pe:"",dt=ct.toLowerCase().indexOf("android")!==-1,M=new WeakMap,Ne="mux.com",Ee,Ce,Re=(Ce=(Ee=T).isSupported)==null?void 0:Ce.call(Ee),lt=dt,pt=()=>D.default.utils.now(),He=D.default.utils.generateUUID,ft=({playbackId:e,customDomain:t=Ne,maxResolution:n,minResolution:a,renditionOrder:r,tokens:{playback:o}={},extraSourceParams:s={}}={})=>{if(!e)return;let[i,l=""]=ce(e),c=new URL(`https://stream.${t}/${i}.m3u8${l}`);return o||c.searchParams.has("token")?(c.searchParams.forEach((d,u)=>{u!="token"&&c.searchParams.delete(u)}),o&&c.searchParams.set("token",o)):(n&&c.searchParams.set("max_resolution",n),a&&(c.searchParams.set("min_resolution",a),n&&+n.slice(0,-1)<+a.slice(0,-1)&&console.error("minResolution must be <= maxResolution","minResolution",a,"maxResolution",n)),r&&c.searchParams.set("rendition_order",r),Object.entries(s).forEach(([d,u])=>{u!=null&&c.searchParams.set(d,u)})),c.toString()},Tt=e=>{if(!e)return;let[t]=e.split("?");return t||void 0},yt=e=>{if(!e||!e.startsWith("https://stream."))return;let[t]=new URL(e).pathname.slice(1).split(".m3u8");return t||void 0},mt=e=>{var t,n,a;return(t=e==null?void 0:e.metadata)!=null&&t.video_id?e.metadata.video_id:te(e)&&(a=(n=Tt(e.playbackId))!=null?n:yt(e.src))!=null?a:e.src},gt=e=>{var t;return(t=M.get(e))==null?void 0:t.error},J=e=>{var t,n;return(n=(t=M.get(e))==null?void 0:t.streamType)!=null?n:g.UNKNOWN},Mt=e=>{var t,n;return(n=(t=M.get(e))==null?void 0:t.targetLiveWindow)!=null?n:Number.NaN},V=e=>{var t,n;return(n=(t=M.get(e))==null?void 0:t.seekable)!=null?n:e.seekable},vt=e=>{var a;let t=(a=M.get(e))==null?void 0:a.liveEdgeStartOffset;if(typeof t!="number")return Number.NaN;let n=V(e);return n.length?n.end(n.length-1)-t:Number.NaN},Z=.034,bt=(e,t,n=Z)=>Math.abs(e-t)<=n,we=(e,t,n=Z)=>e>t||bt(e,t,n),_e=(e,t=Z)=>e.paused&&we(e.currentTime,e.duration,t),ee=(e,t)=>{var c,d,u;if(!t)return;if(e.readyState>2)return!1;let n=t.currentLevel>=0?(d=(c=t.levels)==null?void 0:c[t.currentLevel])==null?void 0:d.details:(u=t.levels.find(p=>!!p.details))==null?void 0:u.details;if(!n||n.live)return;let{fragments:a}=n;if(!(a!=null&&a.length))return;if(e.currentTime<e.duration-(n.targetduration+.5))return!1;let r=a[a.length-1];if(e.currentTime<=r.start)return!1;let o=r.start+r.duration/2,s=e.buffered.start(e.buffered.length-1),i=e.buffered.end(e.buffered.length-1);return o>s&&o<i},Oe=(e,t)=>e.ended||e.loop?e.ended:t&&ee(e,t)?!0:_e(e),xt=(e,t,n)=>{Ve(t,n);let{metadata:a={}}=e,{view_session_id:r=He()}=a,o=mt(e);a.view_session_id=r,a.video_id=o,e.metadata=a,M.set(t,{});let s=Fe(e,t),i=pe(e,t,s);Be(e,t,s),Ke(e,t,s),z(t),j(t);let l=le(e,t,s);return{engine:s,setAutoplay:l,setPreload:i}},Ve=(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",qe),e.removeEventListener("error",Q),e.removeEventListener("durationchange",Ye),M.delete(e),e.dispatchEvent(new Event("teardown")))};function Ue(e,t){var c;let n=A(e);if(!(n===b.M3U8))return!0;let r=!n||((c=t.canPlayType(n))!=null?c:!0),{preferPlayback:o}=e,s=o===R.MSE,i=o===R.NATIVE;return r&&(i||!(Re&&(s||lt)))}var Fe=(e,t)=>{let{debug:n,streamType:a,startTime:r=-1,metadata:o,preferCmcd:s,_hlsConfig:i={}}=e,c=A(e)===b.M3U8,d=Ue(e,t);if(c&&!d&&Re){let u={backBufferLength:30,renderTextTracksNatively:!1,liveDurationInfinity:!0,capLevelToPlayerSize:!0,capLevelOnFPSDrop:!0},p=We(a),f=s!==C.NONE?{useHeaders:s===C.HEADER,sessionId:o==null?void 0:o.view_session_id,contentId:o==null?void 0:o.video_id}:void 0;return new T({debug:n,startPosition:r,cmcd:f,xhrSetup:(k,L)=>{var ne,re;if(s&&s!==C.QUERY)return;let P=new URL(L);if(!P.searchParams.has("CMCD"))return;let ze=((re=(ne=P.searchParams.get("CMCD"))==null?void 0:ne.split(","))!=null?re:[]).filter(ae=>ae.startsWith("sid")||ae.startsWith("cid")).join(",");P.searchParams.set("CMCD",ze),k.open("GET",P)},...u,...p,...i})}},We=e=>e===g.LIVE?{backBufferLength:8}:{},te=({playbackId:e,src:t,customDomain:n})=>{if(e)return!0;if(typeof t!="string")return!1;let a=window==null?void 0:window.location.href,r=new URL(t,a).hostname.toLocaleLowerCase();return r.includes(Ne)||!!n&&r.includes(n.toLocaleLowerCase())},Be=(e,t,n)=>{var s;let{envKey:a,disableTracking:r}=e,o=te(e);if(!r&&(a||o)){let{playerInitTime:i,playerSoftwareName:l,playerSoftwareVersion:c,beaconCollectionDomain:d,debug:u,disableCookies:p}=e,f={...e.metadata,video_title:((s=e==null?void 0:e.metadata)==null?void 0:s.video_title)||void 0},m=k=>typeof k.player_error_code=="string"?!1:typeof e.errorTranslator=="function"?e.errorTranslator(k):k;D.default.monitor(t,{debug:u,beaconCollectionDomain:d,hlsjs:n,Hls:n?T:void 0,automaticErrorTracking:!1,errorTranslator:m,disableCookies:p,data:{...a?{env_key:a}:{},player_software_name:l,player_software:l,player_software_version:c,player_init_time:i,...f}})}},Ke=(e,t,n)=>{var c;let a=Ue(e,t),{src:r}=e,o=()=>{t.ended||!Oe(t,n)||(ee(t,n)?t.currentTime=t.buffered.end(t.buffered.length-1):t.dispatchEvent(new Event("ended")))},s,i,l=()=>{var p,f;let d=(p=V(t))==null?void 0:p.start(0),u=(f=V(t))==null?void 0:f.end(0);(i!==u||s!==d)&&t.dispatchEvent(new CustomEvent("seekablechange",{composed:!0})),s=d,i=u};if(y(t,"durationchange",l),t&&a){let d=A(e);if(typeof r=="string"){let u=()=>{if(J(t)!==g.LIVE||Number.isFinite(t.duration))return;let p=setInterval(l,1e3);t.addEventListener("teardown",()=>{clearInterval(p)},{once:!0}),y(t,"durationchange",()=>{Number.isFinite(t.duration)&&clearInterval(p)})};if(t.preload==="none"){let p=()=>{O(r,t,d).then(u),t.removeEventListener("loadedmetadata",f)},f=()=>{O(r,t,d).then(u),t.removeEventListener("play",p)};y(t,"play",p,{once:!0}),y(t,"loadedmetadata",f,{once:!0})}else O(r,t,d).then(u);t.setAttribute("src",r),e.startTime&&(((c=M.get(t))!=null?c:{}).startTime=e.startTime,t.addEventListener("durationchange",Ye,{once:!0}))}else t.removeAttribute("src");t.addEventListener("error",qe),t.addEventListener("error",Q),t.addEventListener("emptied",()=>{t.querySelectorAll("track[data-removeondestroy]").forEach(p=>{p.remove()})},{once:!0}),y(t,"pause",o),y(t,"seeked",o),y(t,"play",()=>{t.ended||we(t.currentTime,t.duration)&&(t.currentTime=t.seekable.start(0))})}else n&&r?(n.once(T.Events.LEVEL_LOADED,(d,u)=>{Ie(u.details,t,n),l(),J(t)===g.LIVE&&!Number.isFinite(t.duration)&&(n.on(T.Events.LEVEL_UPDATED,l),y(t,"durationchange",()=>{Number.isFinite(t.duration)&&n.off(T.Events.LEVELS_UPDATED,l)}))}),n.on(T.Events.ERROR,(d,u)=>{let p={[T.ErrorTypes.NETWORK_ERROR]:x.MEDIA_ERR_NETWORK,[T.ErrorTypes.MEDIA_ERROR]:x.MEDIA_ERR_DECODE},f=new x("",p[u.type]);f.fatal=u.fatal,f.data=u,t.dispatchEvent(new CustomEvent("error",{detail:f}))}),t.addEventListener("error",Q),y(t,"waiting",o),fe(e,n),Te(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 Ye(e){var a;let t=e.target,n=(a=M.get(t))==null?void 0:a.startTime;if(n&&ue(t.seekable,t.duration,n)){let r=t.preload==="auto";r&&(t.preload="none"),t.currentTime=n,r&&(t.preload="auto")}}async function qe(e){if(!e.isTrusted)return;e.stopImmediatePropagation();let t=e.target;if(!(t!=null&&t.error))return;let{message:n,code:a}=t.error,r=new x(n,a);if(t.src&&(a!==x.MEDIA_ERR_DECODE||a!==void 0))try{let{status:o}=await fetch(t.src);r.data={response:{code:o}}}catch{}t.dispatchEvent(new CustomEvent("error",{detail:r}))}function Q(e){var a,r;if(!(e instanceof CustomEvent)||!(e.detail instanceof x))return;let t=e.target,n=e.detail;!n||!n.fatal||(((a=M.get(t))!=null?a:{}).error=n,(r=t.mux)==null||r.emit("error",{player_error_code:n.code,player_error_message:n.message,player_error_context:n.context}))} | ||
`))}),Se=e=>{var s,u,p;let n=(u=((s=e.find(c=>c.startsWith("#EXT-X-PLAYLIST-TYPE")))!=null?s:"").split(":")[1])==null?void 0:u.trim(),a=U(n),r=F(n),o;if(a===g.LIVE){let c=e.find(i=>i.startsWith("#EXT-X-PART-INF"));if(!!c)o=+c.split(":")[1].split("=")[1]*2;else{let i=e.find(m=>m.startsWith("#EXT-X-TARGETDURATION")),l=(p=i==null?void 0:i.split(":"))==null?void 0:p[1];o=+(l!=null?l:6)*3}}return{streamType:a,targetLiveWindow:r,liveEdgeStartOffset:o}},Ae=async(e,t)=>{if(t===b.MP4)return{streamType:g.ON_DEMAND,targetLiveWindow:Number.NaN,liveEdgeStartOffset:void 0};if(t===b.M3U8){let n=await Ce(e);return Se(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}},O=async(e,t,n=A({src:e}))=>{var s,u,p;let{streamType:a,targetLiveWindow:r,liveEdgeStartOffset:o}=await Ae(e,n);((s=M.get(t))!=null?s:{}).liveEdgeStartOffset=o,((u=M.get(t))!=null?u:{}).targetLiveWindow=r,t.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0})),((p=M.get(t))!=null?p:{}).streamType=a,t.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}))},De=e=>{var s;let t=e.type,n=U(t),a=F(t),r,o=!!((s=e.partList)!=null&&s.length);return n===g.LIVE&&(r=o?e.partTarget*2:e.targetduration*3),{streamType:n,targetLiveWindow:a,liveEdgeStartOffset:r,lowLatency:o}},Ie=(e,t,n)=>{var u,p,c,d,i,l,f,m;let{streamType:a,targetLiveWindow:r,liveEdgeStartOffset:o,lowLatency:s}=De(e);if(a===g.LIVE){s?(n.config.backBufferLength=(u=n.userConfig.backBufferLength)!=null?u:4,n.config.maxFragLookUpTolerance=(p=n.userConfig.maxFragLookUpTolerance)!=null?p:.001,n.config.abrBandWidthUpFactor=(c=n.userConfig.abrBandWidthUpFactor)!=null?c:n.config.abrBandWidthFactor):n.config.backBufferLength=(d=n.userConfig.backBufferLength)!=null?d:8;let k=Object.freeze({get length(){return t.seekable.length},start(L){return t.seekable.start(L)},end(L){var P;return L>this.length||L<0||Number.isFinite(t.duration)?t.seekable.end(L):(P=n.liveSyncPosition)!=null?P:t.seekable.end(L)}});((i=M.get(t))!=null?i:{}).seekable=k}((l=M.get(t))!=null?l:{}).liveEdgeStartOffset=o,((f=M.get(t))!=null?f:{}).targetLiveWindow=r,t.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0})),((m=M.get(t))!=null?m:{}).streamType=a,t.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}))},ke,Pe,ct=(Pe=(ke=globalThis==null?void 0:globalThis.navigator)==null?void 0:ke.userAgent)!=null?Pe:"",dt=ct.toLowerCase().indexOf("android")!==-1,M=new WeakMap,Ne="mux.com",Ee,he,Re=(he=(Ee=T).isSupported)==null?void 0:he.call(Ee),lt=dt,pt=()=>D.default.utils.now(),He=D.default.utils.generateUUID,ft=({playbackId:e,customDomain:t=Ne,maxResolution:n,minResolution:a,renditionOrder:r,programStartTime:o,programEndTime:s,tokens:{playback:u}={},extraSourceParams:p={}}={})=>{if(!e)return;let[c,d=""]=ce(e),i=new URL(`https://stream.${t}/${c}.m3u8${d}`);return u||i.searchParams.has("token")?(i.searchParams.forEach((l,f)=>{f!="token"&&i.searchParams.delete(f)}),u&&i.searchParams.set("token",u)):(n&&i.searchParams.set("max_resolution",n),a&&(i.searchParams.set("min_resolution",a),n&&+n.slice(0,-1)<+a.slice(0,-1)&&console.error("minResolution must be <= maxResolution","minResolution",a,"maxResolution",n)),r&&i.searchParams.set("rendition_order",r),o&&i.searchParams.set("program_start_time",`${o}`),s&&i.searchParams.set("program_end_time",`${s}`),Object.entries(p).forEach(([l,f])=>{f!=null&&i.searchParams.set(l,f)})),i.toString()},Tt=e=>{if(!e)return;let[t]=e.split("?");return t||void 0},yt=e=>{if(!e||!e.startsWith("https://stream."))return;let[t]=new URL(e).pathname.slice(1).split(".m3u8");return t||void 0},mt=e=>{var t,n,a;return(t=e==null?void 0:e.metadata)!=null&&t.video_id?e.metadata.video_id:te(e)&&(a=(n=Tt(e.playbackId))!=null?n:yt(e.src))!=null?a:e.src},gt=e=>{var t;return(t=M.get(e))==null?void 0:t.error},J=e=>{var t,n;return(n=(t=M.get(e))==null?void 0:t.streamType)!=null?n:g.UNKNOWN},Mt=e=>{var t,n;return(n=(t=M.get(e))==null?void 0:t.targetLiveWindow)!=null?n:Number.NaN},V=e=>{var t,n;return(n=(t=M.get(e))==null?void 0:t.seekable)!=null?n:e.seekable},vt=e=>{var a;let t=(a=M.get(e))==null?void 0:a.liveEdgeStartOffset;if(typeof t!="number")return Number.NaN;let n=V(e);return n.length?n.end(n.length-1)-t:Number.NaN},Z=.034,bt=(e,t,n=Z)=>Math.abs(e-t)<=n,we=(e,t,n=Z)=>e>t||bt(e,t,n),_e=(e,t=Z)=>e.paused&&we(e.currentTime,e.duration,t),ee=(e,t)=>{var c,d,i;if(!t)return;if(e.readyState>2)return!1;let n=t.currentLevel>=0?(d=(c=t.levels)==null?void 0:c[t.currentLevel])==null?void 0:d.details:(i=t.levels.find(l=>!!l.details))==null?void 0:i.details;if(!n||n.live)return;let{fragments:a}=n;if(!(a!=null&&a.length))return;if(e.currentTime<e.duration-(n.targetduration+.5))return!1;let r=a[a.length-1];if(e.currentTime<=r.start)return!1;let o=r.start+r.duration/2,s=e.buffered.start(e.buffered.length-1),u=e.buffered.end(e.buffered.length-1);return o>s&&o<u},Oe=(e,t)=>e.ended||e.loop?e.ended:t&&ee(e,t)?!0:_e(e),xt=(e,t,n)=>{Ve(t,n);let{metadata:a={}}=e,{view_session_id:r=He()}=a,o=mt(e);a.view_session_id=r,a.video_id=o,e.metadata=a,M.set(t,{});let s=Fe(e,t),u=pe(e,t,s);Be(e,t,s),Ke(e,t,s),q(t),j(t);let p=le(e,t,s);return{engine:s,setAutoplay:p,setPreload:u}},Ve=(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",$e),e.removeEventListener("error",Q),e.removeEventListener("durationchange",Ye),M.delete(e),e.dispatchEvent(new Event("teardown")))};function Ue(e,t){var c;let n=A(e);if(!(n===b.M3U8))return!0;let r=!n||((c=t.canPlayType(n))!=null?c:!0),{preferPlayback:o}=e,s=o===R.MSE,u=o===R.NATIVE;return r&&(u||!(Re&&(s||lt)))}var Fe=(e,t)=>{let{debug:n,streamType:a,startTime:r=-1,metadata:o,preferCmcd:s,_hlsConfig:u={}}=e,c=A(e)===b.M3U8,d=Ue(e,t);if(c&&!d&&Re){let i={backBufferLength:30,renderTextTracksNatively:!1,liveDurationInfinity:!0,capLevelToPlayerSize:!0,capLevelOnFPSDrop:!0},l=We(a),f=s!==h.NONE?{useHeaders:s===h.HEADER,sessionId:o==null?void 0:o.view_session_id,contentId:o==null?void 0:o.video_id}:void 0;return new T({debug:n,startPosition:r,cmcd:f,xhrSetup:(k,L)=>{var ne,re;if(s&&s!==h.QUERY)return;let P=new URL(L);if(!P.searchParams.has("CMCD"))return;let qe=((re=(ne=P.searchParams.get("CMCD"))==null?void 0:ne.split(","))!=null?re:[]).filter(ae=>ae.startsWith("sid")||ae.startsWith("cid")).join(",");P.searchParams.set("CMCD",qe),k.open("GET",P)},...i,...l,...u})}},We=e=>e===g.LIVE?{backBufferLength:8}:{},te=({playbackId:e,src:t,customDomain:n})=>{if(e)return!0;if(typeof t!="string")return!1;let a=window==null?void 0:window.location.href,r=new URL(t,a).hostname.toLocaleLowerCase();return r.includes(Ne)||!!n&&r.includes(n.toLocaleLowerCase())},Be=(e,t,n)=>{var s;let{envKey:a,disableTracking:r}=e,o=te(e);if(!r&&(a||o)){let{playerInitTime:u,playerSoftwareName:p,playerSoftwareVersion:c,beaconCollectionDomain:d,debug:i,disableCookies:l}=e,f={...e.metadata,video_title:((s=e==null?void 0:e.metadata)==null?void 0:s.video_title)||void 0},m=k=>typeof k.player_error_code=="string"?!1:typeof e.errorTranslator=="function"?e.errorTranslator(k):k;D.default.monitor(t,{debug:i,beaconCollectionDomain:d,hlsjs:n,Hls:n?T:void 0,automaticErrorTracking:!1,errorTranslator:m,disableCookies:l,data:{...a?{env_key:a}:{},player_software_name:p,player_software:p,player_software_version:c,player_init_time:u,...f}})}},Ke=(e,t,n)=>{var c;let a=Ue(e,t),{src:r}=e,o=()=>{t.ended||!Oe(t,n)||(ee(t,n)?t.currentTime=t.buffered.end(t.buffered.length-1):t.dispatchEvent(new Event("ended")))},s,u,p=()=>{var l,f;let d=(l=V(t))==null?void 0:l.start(0),i=(f=V(t))==null?void 0:f.end(0);(u!==i||s!==d)&&t.dispatchEvent(new CustomEvent("seekablechange",{composed:!0})),s=d,u=i};if(y(t,"durationchange",p),t&&a){let d=A(e);if(typeof r=="string"){let i=()=>{if(J(t)!==g.LIVE||Number.isFinite(t.duration))return;let l=setInterval(p,1e3);t.addEventListener("teardown",()=>{clearInterval(l)},{once:!0}),y(t,"durationchange",()=>{Number.isFinite(t.duration)&&clearInterval(l)})};if(t.preload==="none"){let l=()=>{O(r,t,d).then(i),t.removeEventListener("loadedmetadata",f)},f=()=>{O(r,t,d).then(i),t.removeEventListener("play",l)};y(t,"play",l,{once:!0}),y(t,"loadedmetadata",f,{once:!0})}else O(r,t,d).then(i);t.setAttribute("src",r),e.startTime&&(((c=M.get(t))!=null?c:{}).startTime=e.startTime,t.addEventListener("durationchange",Ye,{once:!0}))}else t.removeAttribute("src");t.addEventListener("error",$e),t.addEventListener("error",Q),t.addEventListener("emptied",()=>{t.querySelectorAll("track[data-removeondestroy]").forEach(l=>{l.remove()})},{once:!0}),y(t,"pause",o),y(t,"seeked",o),y(t,"play",()=>{t.ended||we(t.currentTime,t.duration)&&(t.currentTime=t.seekable.start(0))})}else n&&r?(n.once(T.Events.LEVEL_LOADED,(d,i)=>{Ie(i.details,t,n),p(),J(t)===g.LIVE&&!Number.isFinite(t.duration)&&(n.on(T.Events.LEVEL_UPDATED,p),y(t,"durationchange",()=>{Number.isFinite(t.duration)&&n.off(T.Events.LEVELS_UPDATED,p)}))}),n.on(T.Events.ERROR,(d,i)=>{let l={[T.ErrorTypes.NETWORK_ERROR]:x.MEDIA_ERR_NETWORK,[T.ErrorTypes.MEDIA_ERROR]:x.MEDIA_ERR_DECODE},f=new x("",l[i.type]);f.fatal=i.fatal,f.data=i,t.dispatchEvent(new CustomEvent("error",{detail:f}))}),t.addEventListener("error",Q),y(t,"waiting",o),fe(e,n),Te(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 Ye(e){var a;let t=e.target,n=(a=M.get(t))==null?void 0:a.startTime;if(n&&ue(t.seekable,t.duration,n)){let r=t.preload==="auto";r&&(t.preload="none"),t.currentTime=n,r&&(t.preload="auto")}}async function $e(e){if(!e.isTrusted)return;e.stopImmediatePropagation();let t=e.target;if(!(t!=null&&t.error))return;let{message:n,code:a}=t.error,r=new x(n,a);if(t.src&&(a!==x.MEDIA_ERR_DECODE||a!==void 0))try{let{status:o}=await fetch(t.src);r.data={response:{code:o}}}catch{}t.dispatchEvent(new CustomEvent("error",{detail:r}))}function Q(e){var a,r;if(!(e instanceof CustomEvent)||!(e.detail instanceof x))return;let t=e.target,n=e.detail;!n||!n.fatal||(((a=M.get(t))!=null?a:{}).error=n,(r=t.mux)==null||r.emit("error",{player_error_code:n.code,player_error_message:n.message,player_error_context:n.context}))} | ||
//# sourceMappingURL=index.cjs.js.map |
@@ -30,3 +30,3 @@ { | ||
"src/types.ts": { | ||
"bytes": 5652, | ||
"bytes": 5706, | ||
"imports": [], | ||
@@ -127,3 +127,3 @@ "format": "esm" | ||
"src/index.ts": { | ||
"bytes": 35767, | ||
"bytes": 36067, | ||
"imports": [ | ||
@@ -194,3 +194,3 @@ { | ||
"inputs": {}, | ||
"bytes": 2133689 | ||
"bytes": 2134220 | ||
}, | ||
@@ -291,8 +291,8 @@ "dist/playback-core.mjs": { | ||
"src/index.ts": { | ||
"bytesInOutput": 10509 | ||
"bytesInOutput": 10645 | ||
} | ||
}, | ||
"bytes": 501693 | ||
"bytes": 501829 | ||
} | ||
} | ||
} |
@@ -47,2 +47,4 @@ /// <reference types="mux-embed/dist/types/mux-embed" /> | ||
renditionOrder: RenditionOrderValue; | ||
programStartTime: number; | ||
programEndTime: number; | ||
tokens: Partial<{ | ||
@@ -55,3 +57,3 @@ playback: string; | ||
}>; | ||
export declare const toMuxVideoURL: ({ playbackId: playbackIdWithParams, customDomain: domain, maxResolution, minResolution, renditionOrder, tokens: { playback: token }, extraSourceParams, }?: MuxVideoURLProps) => string | undefined; | ||
export declare const toMuxVideoURL: ({ playbackId: playbackIdWithParams, customDomain: domain, maxResolution, minResolution, renditionOrder, programStartTime, programEndTime, tokens: { playback: token }, extraSourceParams, }?: MuxVideoURLProps) => string | undefined; | ||
export declare const getError: (mediaEl: HTMLMediaElement) => globalThis.MediaError | (globalThis.MediaError & MediaError) | null | undefined; | ||
@@ -58,0 +60,0 @@ export declare const getStreamType: (mediaEl: HTMLMediaElement) => ValueOf<StreamTypes>; |
@@ -107,2 +107,4 @@ /// <reference types="mux-embed/dist/types/mux-embed" /> | ||
preferPlayback: ValueOf<PlaybackTypes> | undefined; | ||
programStartTime: number; | ||
programEndTime: number; | ||
renditionOrder: RenditionOrderValue; | ||
@@ -109,0 +111,0 @@ startTime: Hls['config']['startPosition']; |
@@ -47,2 +47,4 @@ /// <reference types="mux-embed/dist/types/mux-embed" /> | ||
renditionOrder: RenditionOrderValue; | ||
programStartTime: number; | ||
programEndTime: number; | ||
tokens: Partial<{ | ||
@@ -55,3 +57,3 @@ playback: string; | ||
}>; | ||
export declare const toMuxVideoURL: ({ playbackId: playbackIdWithParams, customDomain: domain, maxResolution, minResolution, renditionOrder, tokens: { playback: token }, extraSourceParams, }?: MuxVideoURLProps) => string | undefined; | ||
export declare const toMuxVideoURL: ({ playbackId: playbackIdWithParams, customDomain: domain, maxResolution, minResolution, renditionOrder, programStartTime, programEndTime, tokens: { playback: token }, extraSourceParams, }?: MuxVideoURLProps) => string | undefined; | ||
export declare const getError: (mediaEl: HTMLMediaElement) => globalThis.MediaError | (globalThis.MediaError & MediaError) | null | undefined; | ||
@@ -58,0 +60,0 @@ export declare const getStreamType: (mediaEl: HTMLMediaElement) => ValueOf<StreamTypes>; |
@@ -107,2 +107,4 @@ /// <reference types="mux-embed/dist/types/mux-embed" /> | ||
preferPlayback: ValueOf<PlaybackTypes> | undefined; | ||
programStartTime: number; | ||
programEndTime: number; | ||
renditionOrder: RenditionOrderValue; | ||
@@ -109,0 +111,0 @@ startTime: Hls['config']['startPosition']; |
{ | ||
"name": "@mux/playback-core", | ||
"version": "0.23.1-canary.0-84392f1", | ||
"version": "0.23.1-canary.0-845493b", | ||
"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
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
5634831
38
5734