Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@mux/playback-core

Package Overview
Dependencies
Maintainers
1
Versions
585
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mux/playback-core - npm Package Compare versions

Comparing version 0.23.1 to 0.24.0-canary.0-367275a

CHANGELOG.md

6

dist/index.cjs.js

@@ -1,4 +0,4 @@

"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:()=>b,Hls:()=>T,MaxResolution:()=>Ge,MediaError:()=>x,MimeTypeShorthandMap:()=>S,MinResolution:()=>je,PlaybackTypes:()=>w,RenditionOrder:()=>Qe,StreamTypes:()=>m,addCuePoints:()=>B,addTextTrack:()=>H,allMediaTypes:()=>Xe,generatePlayerInitTime:()=>rt,generateUUID:()=>Ee,getActiveCuePoint:()=>K,getCuePoints:()=>le,getCuePointsTrack:()=>D,getCurrentPdt:()=>fe,getEnded:()=>Ce,getError:()=>ct,getLiveEdgeStart:()=>dt,getMediaPlaylistLinesFromMultivariantPlaylistSrc:()=>Me,getSeekable:()=>O,getStartDate:()=>pe,getStreamInfoFromHlsjsLevelDetails:()=>xe,getStreamInfoFromPlaylistLines:()=>ve,getStreamInfoFromSrcAndType:()=>be,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:()=>Y,setupHls:()=>Ie,setupMux:()=>Re,shorthandKeys:()=>ze,teardown:()=>Ae,toMuxVideoURL:()=>ot,updateStreamInfoFromHlsjsLevelDetails:()=>Le,updateStreamInfoFromSrc:()=>_});module.exports=Ye(ft);var I=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 i;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=(i=v.defaultMessages[this.code])!=null?i:"")}};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,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),b={M3U8:"application/vnd.apple.mpegurl",MP4:"video/mp4"},S={HLS:b.M3U8},ze=Object.keys(S),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 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):""},V=t=>t==="VOD"?m.ON_DEMAND:m.LIVE,U=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,b)?b[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,i=oe(r)?r:!!r,c=()=>{o||y(e,"playing",()=>{o=!0},{once:!0})};if(c(),y(e,"loadstart",()=>{o=!1,c(),F(e,i)},{once:!0}),y(e,"loadstart",()=>{n||(t.streamType&&t.streamType!==m.UNKNOWN?a=t.streamType===m.LIVE:a=!Number.isFinite(e.duration)),F(e,i)},{once:!0}),n&&n.once(T.Events.LEVEL_LOADED,(u,d)=>{var s;t.streamType&&t.streamType!==m.UNKNOWN?a=t.streamType===m.LIVE:a=(s=d.details.live)!=null?s:!1}),!i){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||(i=oe(u)?u:!!u,F(e,i))}},F=(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=s=>{s!=null&&["","none","metadata","auto"].includes(s)?n.setAttribute("preload",s):n.removeAttribute("preload")};if(!r)return o(t),o;let a=!1,i=!1,c=r.config.maxBufferLength,p=r.config.maxBufferSize,u=s=>{o(s);let l=s!=null?s:n.preload;i||l==="none"||(l==="metadata"?(r.config.maxBufferLength=1,r.config.maxBufferSize=1):(r.config.maxBufferLength=c,r.config.maxBufferSize=p),d())},d=()=>{!a&&e&&(a=!0,r.loadSource(e))};return y(n,"play",()=>{i=!0,r.config.maxBufferLength=c,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){c();let s=t.addVideoTrack("main");s.selected=!0;for(let[l,f]of d.levels.entries()){let M=s.addRendition(f.url[0],f.width,f.height,f.videoCodec,f.bitrate);n.set(f,`${l}`),M.id=`${l}`}}),e.on(T.Events.AUDIO_TRACKS_UPDATED,function(u,d){i();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(M=>n.get(M));for(let M of t.videoRenditions)M.id&&!l.includes(M.id)&&s.removeRendition(M)});let r=u=>{let d=u.target.selectedIndex;d!=e.nextLevel&&o(d)},o=u=>{let d=t.currentTime,s=!1,l=(f,M)=>{s||(s=!Number.isFinite(M.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)},i=()=>{for(let u of t.audioTracks)t.removeAudioTrack(u)},c=()=>{a(),i()};e.once(T.Events.DESTROYING,c)}function ce(t,e){e.on(T.Events.NON_NATIVE_TEXT_TRACKS_FOUND,(o,{tracks:a})=>{a.forEach(i=>{var u;let c=(u=i.subtitleTrack)!=null?u:i.closedCaptions,p=e.subtitleTracks.findIndex(({lang:d,name:s,type:l})=>d==(c==null?void 0:c.lang)&&s===i.label&&l.toLowerCase()===i.kind);H(t,i.kind,i.label,c==null?void 0:c.lang,`${i.kind}${p}`)})});let n=()=>{var i;if(!e.subtitleTracks.length)return;let o=Array.from(t.textTracks).find(c=>c.id&&c.mode==="showing"&&["subtitles","captions"].includes(c.kind)),a=`${(i=e.subtitleTracks[e.subtitleTrack])==null?void 0:i.type.toLowerCase()}${e.subtitleTrack}`;if(o&&(e.subtitleTrack<0||(o==null?void 0:o.id)!==a)){let c=e.subtitleTracks.findIndex(({lang:p,name:u,type:d})=>p==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:i})=>{let c=t.textTracks.getTrackById(a);if(!c)return;let p=c.mode==="disabled";p&&(c.mode="hidden"),i.forEach(u=>{var d;(d=c.cues)!=null&&d.getCueById(u.id)||c.addCue(u)}),p&&(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,i;if(!["subtitles","caption"].includes(o.kind)&&o.label==="thumbnails"){if(!((a=o.cues)!=null&&a.length)){let c=t.querySelector('track[label="thumbnails"]'),p=(i=c==null?void 0:c.getAttribute("src"))!=null?i:"";c==null||c.removeAttribute("src"),setTimeout(()=>{c==null||c.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 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",W=Object.freeze({label:A}),D=(t,{label:e=A}=W)=>{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 B(t,e,n=W){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 s,l;let i=Array.prototype.findIndex.call(r==null?void 0:r.cues,f=>f.startTime>=o),c=(s=r==null?void 0:r.cues)==null?void 0:s[i],p=c?c.startTime:Number.isFinite(t.duration)?t.duration:Number.MAX_SAFE_INTEGER,u=(l=r==null?void 0:r.cues)==null?void 0:l[i-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:A}){let n=D(t,e);return n!=null&&n.cues?Array.from(n.cues,r=>de(r)):[]}function K(t,e={label:A}){var a,i;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((i=n.activeCues)!=null?i:[],({startTime:c,endTime:p})=>c<=r&&p>r);return de(o)}async function Y(t,e=W){return new Promise(n=>{y(t,"loadstart",async()=>{let r=await B(t,[],e);y(t,"cuechange",()=>{let o=K(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 i,c,p;let n=(c=((i=t.find(u=>u.startsWith("#EXT-X-PLAYLIST-TYPE")))!=null?i:"").split(":")[1])==null?void 0:c.trim(),r=V(n),o=U(n),a;if(r===m.LIVE){let u=t.find(s=>s.startsWith("#EXT-X-PART-INF"));if(!!u)a=+u.split(":")[1].split("=")[1]*2;else{let s=t.find(M=>M.startsWith("#EXT-X-TARGETDURATION")),l=(p=s==null?void 0:s.split(":"))==null?void 0:p[1];a=+(l!=null?l:6)*3}}return{streamType:r,targetLiveWindow:o,liveEdgeStartOffset:a}},be=async(t,e)=>{if(e===b.MP4)return{streamType:m.ON_DEMAND,targetLiveWindow:Number.NaN,liveEdgeStartOffset:void 0};if(e===b.M3U8){let n=await Me(t);return ve(n)}return console.error(`Media type ${e} is an unrecognized or unsupported type for src ${t}.`),{streamType:void 0,targetLiveWindow:void 0,liveEdgeStartOffset:void 0}},_=async(t,e,n=C({src:t}))=>{var i,c,p;let{streamType:r,targetLiveWindow:o,liveEdgeStartOffset:a}=await be(t,n);((i=g.get(e))!=null?i:{}).liveEdgeStartOffset=a,((c=g.get(e))!=null?c:{}).targetLiveWindow=o,e.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0})),((p=g.get(e))!=null?p:{}).streamType=r,e.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}))},xe=t=>{var i;let e=t.type,n=V(e),r=U(e),o,a=!!((i=t.partList)!=null&&i.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,p,u,d,s,l,f,M;let{streamType:r,targetLiveWindow:o,liveEdgeStartOffset:a,lowLatency:i}=xe(t);if(r===m.LIVE){i?(n.config.backBufferLength=(c=n.userConfig.backBufferLength)!=null?c: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 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)}});((s=g.get(e))!=null?s:{}).seekable=P}((l=g.get(e))!=null?l:{}).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:i={}}={})=>{if(!t)return;let[c,p=""]=re(t),u=new URL(`https://stream.${e}/${c}.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(i).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=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},O=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=O(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,i=t.buffered.start(t.buffered.length-1),c=t.buffered.end(t.buffered.length-1);return a>i&&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 i=Ie(t,e),c=se(t,e,i);Re(t,e,i),we(t,e,i),Y(e);let p=ae(t,e,i);return{engine:i,setAutoplay:p,setPreload:c}},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===b.M3U8))return!0;let o=!n||((u=e.canPlayType(n))!=null?u:!0),{preferPlayback:a}=t,i=a===w.MSE,c=a===w.NATIVE;return o&&(c||!(ke&&(i||nt)))}var Ie=(t,e)=>{let{debug:n,streamType:r,startTime:o=-1,metadata:a,preferCmcd:i,_hlsConfig:c={}}=t,u=C(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=i!==E.NONE?{useHeaders:i===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(i&&i!==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)},...s,...l,...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 i;let{envKey:r,disableTracking:o}=t,a=G(t);if(!o&&(r||a)){let{playerInitTime:c,playerSoftwareName:p,playerSoftwareVersion:u,beaconCollectionDomain:d,debug:s,disableCookies:l}=t,f={...t.metadata,video_title:((i=t==null?void 0:t.metadata)==null?void 0:i.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:s,beaconCollectionDomain:d,hlsjs:n,Hls:n?T:void 0,automaticErrorTracking:!1,errorTranslator:M,disableCookies:l,data:{...r?{env_key:r}:{},player_software_name:p,player_software:p,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")))},i,c,p=()=>{var l,f;let d=(l=O(e))==null?void 0:l.start(0),s=(f=O(e))==null?void 0:f.end(0);(c!==s||i!==d)&&e.dispatchEvent(new CustomEvent("seekablechange",{composed:!0})),i=d,c=s};if(y(e,"durationchange",p),e&&r){let d=C(t);if(typeof o=="string"){let s=()=>{if(q(e)!==m.LIVE||Number.isFinite(e.duration))return;let l=setInterval(p,1e3);e.addEventListener("teardown",()=>{clearInterval(l)},{once:!0}),y(e,"durationchange",()=>{Number.isFinite(e.duration)&&clearInterval(l)})};if(e.preload==="none"){let l=()=>{_(o,e,d).then(s),e.removeEventListener("loadedmetadata",f)},f=()=>{_(o,e,d).then(s),e.removeEventListener("play",l)};y(e,"play",l,{once:!0}),y(e,"loadedmetadata",f,{once:!0})}else _(o,e,d).then(s);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(l=>{l.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,s)=>{Le(s.details,e,n),p(),q(e)===m.LIVE&&!Number.isFinite(e.duration)&&(n.on(T.Events.LEVEL_UPDATED,p),y(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",$),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}))}
"use strict";var tt=Object.create;var N=Object.defineProperty;var nt=Object.getOwnPropertyDescriptor;var rt=Object.getOwnPropertyNames;var at=Object.getPrototypeOf,ot=Object.prototype.hasOwnProperty;var st=(e,t)=>{for(var n in t)N(e,n,{get:t[n],enumerable:!0})},de=(e,t,n,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of rt(t))!ot.call(e,r)&&r!==n&&N(e,r,{get:()=>t[r],enumerable:!(a=nt(t,r))||a.enumerable});return e};var pe=(e,t,n)=>(n=e!=null?tt(at(e)):{},de(t||!e||!e.__esModule?N(n,"default",{value:e,enumerable:!0}):n,e)),it=e=>de(N({},"__esModule",{value:!0}),e);var At={};st(At,{AutoplayTypes:()=>h,CmcdTypeValues:()=>ut,CmcdTypes:()=>C,ExtensionMimeTypeMap:()=>b,Hls:()=>T,MaxResolution:()=>lt,MediaError:()=>x,MimeTypeShorthandMap:()=>S,MinResolution:()=>ft,PlaybackTypes:()=>_,RenditionOrder:()=>Tt,StreamTypes:()=>g,addChapters:()=>J,addCuePoints:()=>z,addTextTrack:()=>U,allMediaTypes:()=>pt,generatePlayerInitTime:()=>bt,generateUUID:()=>Ve,getActiveChapter:()=>Q,getActiveCuePoint:()=>X,getAppCertificate:()=>ze,getChapters:()=>Ee,getCuePoints:()=>ke,getCurrentPdt:()=>he,getDRMConfig:()=>Ye,getEnded:()=>We,getError:()=>Pt,getLicenseKey:()=>Xe,getLiveEdgeStart:()=>Ct,getMediaPlaylistLinesFromMultivariantPlaylistSrc:()=>Ie,getSeekable:()=>W,getStartDate:()=>Ce,getStreamInfoFromHlsjsLevelDetails:()=>He,getStreamInfoFromPlaylistLines:()=>Re,getStreamInfoFromSrcAndType:()=>Ne,getStreamType:()=>ee,getStreamTypeConfig:()=>qe,getTargetLiveWindow:()=>Et,getTextTrack:()=>P,initialize:()=>St,isKeyOf:()=>H,isMuxVideoSrc:()=>se,isPseudoEnded:()=>Fe,isStuckOnLastFragment:()=>ae,loadMedia:()=>Je,mux:()=>D.default,muxMediaState:()=>M,removeTextTrack:()=>be,setupChapters:()=>Z,setupCuePoints:()=>G,setupHls:()=>$e,setupMux:()=>je,setupNativeFairplayDRM:()=>Ge,shorthandKeys:()=>dt,teardown:()=>Ke,toAppCertURL:()=>oe,toLicenseKeyURL:()=>w,toMuxVideoURL:()=>xt,toPlaybackIdFromSrc:()=>ne,updateStreamInfoFromHlsjsLevelDetails:()=>_e,updateStreamInfoFromSrc:()=>F});module.exports=it(At);var D=pe(require("mux-embed"));var le=pe(require("hls.js")),T=le.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 ct=e=>e==null,H=(e,t)=>ct(t)?!1:e in t,h={ANY:"any",MUTED:"muted"},g={ON_DEMAND:"on-demand",LIVE:"live",UNKNOWN:"unknown"},_={MSE:"mse",NATIVE:"native"},C={HEADER:"header",QUERY:"query",NONE:"none"},ut=Object.values(C),b={M3U8:"application/vnd.apple.mpegurl",MP4:"video/mp4"},S={HLS:b.M3U8},dt=Object.keys(S),pt=[...Object.values(b),"hls","HLS"],lt={upTo720p:"720p",upTo1080p:"1080p",upTo1440p:"1440p",upTo2160p:"2160p"},ft={noLessThan480p:"480p",noLessThan540p:"540p",noLessThan720p:"720p",noLessThan1080p:"1080p",noLessThan1440p:"1440p",noLessThan2160p:"2160p"},Tt={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 fe(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 Te=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 H(a,S)?S[a]:t}let{src:n}=e;return n?yt(n):""},K=e=>e==="VOD"?g.ON_DEMAND:g.LIVE,B=e=>e==="EVENT"?Number.POSITIVE_INFINITY:e==="VOD"?Number.NaN:0,yt=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 H(r,b)?b[r]:""};var mt=Object.values(h),ye=e=>typeof e=="boolean"||typeof e=="string"&&mt.includes(e),me=(e,t,n)=>{let{autoplay:a}=e,r=!1,o=!1,s=ye(a)?a:!!a,c=()=>{r||y(t,"playing",()=>{r=!0},{once:!0})};if(c(),y(t,"loadstart",()=>{r=!1,c(),$(t,s)},{once:!0}),y(t,"loadstart",()=>{n||(e.streamType&&e.streamType!==g.UNKNOWN?o=e.streamType===g.LIVE:o=!Number.isFinite(t.duration)),$(t,s)},{once:!0}),n&&n.once(T.Events.LEVEL_LOADED,(u,d)=>{var i;e.streamType&&e.streamType!==g.UNKNOWN?o=e.streamType===g.LIVE:o=(i=d.details.live)!=null?i:!1}),!s){let u=()=>{!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,u):u()},{once:!0})}return u=>{r||(s=ye(u)?u:!!u,$(t,s))}},$=(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 ge=({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,c=a.config.maxBufferLength,p=a.config.maxBufferSize,u=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=c,a.config.maxBufferSize=p),d())},d=()=>{!o&&t&&(o=!0,a.loadSource(t))};return y(n,"play",()=>{s=!0,a.config.maxBufferLength=c,a.config.maxBufferSize=p,d()},{once:!0}),u(e),u};function Me(e,t){var p;if(!("videoTracks"in e))return;let n=new WeakMap;t.on(T.Events.MANIFEST_PARSED,function(u,d){c();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(u,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 u=+((i=[...e.audioTracks].find(l=>l.enabled))==null?void 0:i.id),d=t.audioTracks.map(l=>l.id);u!=t.audioTrack&&d.includes(u)&&(t.audioTrack=u)}),t.on(T.Events.LEVELS_UPDATED,function(u,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=u=>{let d=u.target.selectedIndex;d!=t.nextLevel&&r(d)},r=u=>{let d=e.currentTime,i=!1,l=(f,m)=>{i||(i=!Number.isFinite(m.endOffset))};t.on(T.Events.BUFFER_FLUSHING,l),t.nextLevel=u,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 u of e.videoTracks)e.removeVideoTrack(u)},s=()=>{for(let u of e.audioTracks)e.removeAudioTrack(u)},c=()=>{o(),s()};t.once(T.Events.DESTROYING,c)}var q=e=>"time"in e?e.time:e.startTime;function ve(e,t){t.on(T.Events.NON_NATIVE_TEXT_TRACKS_FOUND,(r,{tracks:o})=>{o.forEach(s=>{var u;let c=(u=s.subtitleTrack)!=null?u:s.closedCaptions,p=t.subtitleTracks.findIndex(({lang:d,name:i,type:l})=>d==(c==null?void 0:c.lang)&&i===s.label&&l.toLowerCase()===s.kind);U(e,s.kind,s.label,c==null?void 0:c.lang,`${s.kind}${p}`)})});let n=()=>{var s;if(!t.subtitleTracks.length)return;let r=Array.from(e.textTracks).find(c=>c.id&&c.mode==="showing"&&["subtitles","captions"].includes(c.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 c=t.subtitleTracks.findIndex(({lang:p,name:u,type:d})=>p==r.language&&u===r.label&&d.toLowerCase()===r.kind);t.subtitleTrack=c}r&&(r==null?void 0:r.id)===o&&r.cues&&Array.from(r.cues).forEach(c=>{r.addCue(c)})};e.textTracks.addEventListener("change",n),t.on(T.Events.CUES_PARSED,(r,{track:o,cues:s})=>{let c=e.textTracks.getTrackById(o);if(!c)return;let p=c.mode==="disabled";p&&(c.mode="hidden"),s.forEach(u=>{var d;(d=c.cues)!=null&&d.getCueById(u.id)||c.addCue(u)}),p&&(c.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 c=e.querySelector('track[label="thumbnails"]'),p=(s=c==null?void 0:c.getAttribute("src"))!=null?s:"";c==null||c.removeAttribute("src"),setTimeout(()=>{c==null||c.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 U(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 be(e,t){let n=Array.prototype.find.call(e.querySelectorAll("track"),a=>a.track===t);n==null||n.remove()}function P(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 xe(e,t,n,a){let r=P(e,n,a);return r||(r=U(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)=>q(s)-q(o)).forEach(o=>{var p,u;let s=o.value,c=q(o);if("endTime"in o&&o.endTime!=null)r==null||r.addCue(new VTTCue(c,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>=c),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=(u=r==null?void 0:r.cues)==null?void 0:u[d-1];f&&(f.endTime=c),r==null||r.addCue(new VTTCue(c,l,a==="chapters"?s:JSON.stringify(s!=null?s:null)))}}),e.textTracks.dispatchEvent(new Event("change",{bubbles:!0,composed:!0})),r}var Y="cuepoints",Le=Object.freeze({label:Y});async function z(e,t,n=Le){return xe(e,t,n.label,"metadata")}var O=e=>({time:e.startTime,value:JSON.parse(e.text)});function ke(e,t={label:Y}){let n=P(e,t.label,"metadata");return n!=null&&n.cues?Array.from(n.cues,a=>O(a)):[]}function X(e,t={label:Y}){var o,s;let n=P(e,t.label,"metadata");if(!((o=n==null?void 0:n.activeCues)!=null&&o.length))return;if(n.activeCues.length===1)return O(n.activeCues[0]);let{currentTime:a}=e,r=Array.prototype.find.call((s=n.activeCues)!=null?s:[],({startTime:c,endTime:p})=>c<=a&&p>a);return O(r||n.activeCues[0])}async function G(e,t=Le){return new Promise(n=>{y(e,"loadstart",async()=>{let a=await z(e,[],t);y(e,"cuechange",()=>{let r=X(e);if(r){let o=new CustomEvent("cuepointchange",{composed:!0,bubbles:!0,detail:r});e.dispatchEvent(o)}},{},a),n(a)})})}var j="chapters",Pe=Object.freeze({label:j}),V=e=>({startTime:e.startTime,endTime:e.endTime,value:e.text});async function J(e,t,n=Pe){return xe(e,t,n.label,"chapters")}function Ee(e,t={label:j}){var a;let n=P(e,t.label,"chapters");return(a=n==null?void 0:n.cues)!=null&&a.length?Array.from(n.cues,r=>V(r)):[]}function Q(e,t={label:j}){var o,s;let n=P(e,t.label,"chapters");if(!((o=n==null?void 0:n.activeCues)!=null&&o.length))return;if(n.activeCues.length===1)return V(n.activeCues[0]);let{currentTime:a}=e,r=Array.prototype.find.call((s=n.activeCues)!=null?s:[],({startTime:c,endTime:p})=>c<=a&&p>a);return V(r||n.activeCues[0])}async function Z(e,t=Pe){return new Promise(n=>{y(e,"loadstart",async()=>{let a=await J(e,[],t);y(e,"cuechange",()=>{let r=Q(e);if(r){let o=new CustomEvent("chapterchange",{composed:!0,bubbles:!0,detail:r});e.dispatchEvent(o)}},{},a),n(a)})})}function Ce(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 he(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 Ie=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(`
`))}),Re=e=>{var s,c,p;let n=(c=((s=e.find(u=>u.startsWith("#EXT-X-PLAYLIST-TYPE")))!=null?s:"").split(":")[1])==null?void 0:c.trim(),a=K(n),r=B(n),o;if(a===g.LIVE){let u=e.find(i=>i.startsWith("#EXT-X-PART-INF"));if(!!u)o=+u.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}},Ne=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 Ie(e);return Re(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}},F=async(e,t,n=A({src:e}))=>{var s,c,p;let{streamType:a,targetLiveWindow:r,liveEdgeStartOffset:o}=await Ne(e,n);((s=M.get(t))!=null?s:{}).liveEdgeStartOffset=o,((c=M.get(t))!=null?c:{}).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}))},He=e=>{var s;let t=e.type,n=K(t),a=B(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}},_e=(e,t,n)=>{var c,p,u,d,i,l,f,m;let{streamType:a,targetLiveWindow:r,liveEdgeStartOffset:o,lowLatency:s}=He(e);if(a===g.LIVE){s?(n.config.backBufferLength=(c=n.userConfig.backBufferLength)!=null?c: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 E=Object.freeze({get length(){return t.seekable.length},start(L){return t.seekable.start(L)},end(L){var I;return L>this.length||L<0||Number.isFinite(t.duration)?t.seekable.end(L):(I=n.liveSyncPosition)!=null?I:t.seekable.end(L)}});((i=M.get(t))!=null?i:{}).seekable=E}((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}))},Se,Ae,gt=(Ae=(Se=globalThis==null?void 0:globalThis.navigator)==null?void 0:Se.userAgent)!=null?Ae:"",Mt=gt.toLowerCase().indexOf("android")!==-1,M=new WeakMap,k="mux.com",we,De,Oe=(De=(we=T).isSupported)==null?void 0:De.call(we),vt=Mt,bt=()=>D.default.utils.now(),Ve=D.default.utils.generateUUID,xt=({playbackId:e,customDomain:t=k,maxResolution:n,minResolution:a,renditionOrder:r,programStartTime:o,programEndTime:s,tokens:{playback:c}={},extraSourceParams:p={}}={})=>{if(!e)return;let[u,d=""]=Te(e),i=new URL(`https://stream.${t}/${u}.m3u8${d}`);return c||i.searchParams.has("token")?(i.searchParams.forEach((l,f)=>{f!="token"&&i.searchParams.delete(f)}),c&&i.searchParams.set("token",c)):(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()},Lt=e=>{if(!e)return;let[t]=e.split("?");return t||void 0},ne=e=>{if(!e||!e.startsWith("https://stream."))return;let[t]=new URL(e).pathname.slice(1).split(".m3u8");return t||void 0},kt=e=>{var t,n,a;return(t=e==null?void 0:e.metadata)!=null&&t.video_id?e.metadata.video_id:se(e)&&(a=(n=Lt(e.playbackId))!=null?n:ne(e.src))!=null?a:e.src},Pt=e=>{var t;return(t=M.get(e))==null?void 0:t.error},ee=e=>{var t,n;return(n=(t=M.get(e))==null?void 0:t.streamType)!=null?n:g.UNKNOWN},Et=e=>{var t,n;return(n=(t=M.get(e))==null?void 0:t.targetLiveWindow)!=null?n:Number.NaN},W=e=>{var t,n;return(n=(t=M.get(e))==null?void 0:t.seekable)!=null?n:e.seekable},Ct=e=>{var a;let t=(a=M.get(e))==null?void 0:a.liveEdgeStartOffset;if(typeof t!="number")return Number.NaN;let n=W(e);return n.length?n.end(n.length-1)-t:Number.NaN},re=.034,ht=(e,t,n=re)=>Math.abs(e-t)<=n,Ue=(e,t,n=re)=>e>t||ht(e,t,n),Fe=(e,t=re)=>e.paused&&Ue(e.currentTime,e.duration,t),ae=(e,t)=>{var u,d,i;if(!t)return;if(e.readyState>2)return!1;let n=t.currentLevel>=0?(d=(u=t.levels)==null?void 0:u[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),c=e.buffered.end(e.buffered.length-1);return o>s&&o<c},We=(e,t)=>e.ended||e.loop?e.ended:t&&ae(e,t)?!0:Fe(e),St=(e,t,n)=>{Ke(t,n);let{metadata:a={}}=e,{view_session_id:r=Ve()}=a,o=kt(e);a.view_session_id=r,a.video_id=o,e.metadata=a,M.set(t,{});let s=$e(e,t),c=ge(e,t,s);je(e,t,s),Je(e,t,s),G(t),Z(t);let p=me(e,t,s);return{engine:s,setAutoplay:p,setPreload:c}},Ke=(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",Ze),e.removeEventListener("error",te),e.removeEventListener("durationchange",Qe),M.delete(e),e.dispatchEvent(new Event("teardown")))};function Be(e,t){var u;let n=A(e);if(!(n===b.M3U8))return!0;let r=!n||((u=t.canPlayType(n))!=null?u:!0),{preferPlayback:o}=e,s=o===_.MSE,c=o===_.NATIVE;return r&&(c||!(Oe&&(s||vt)))}var $e=(e,t)=>{let{debug:n,streamType:a,startTime:r=-1,metadata:o,preferCmcd:s,_hlsConfig:c={}}=e,u=A(e)===b.M3U8,d=Be(e,t);if(u&&!d&&Oe){let i={backBufferLength:30,renderTextTracksNatively:!1,liveDurationInfinity:!0,capLevelToPlayerSize:!0,capLevelOnFPSDrop:!0},l=qe(a),f=Ye(e),m=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:m,xhrSetup:(L,I)=>{var ie,ce;if(s&&s!==C.QUERY)return;let R=new URL(I);if(!R.searchParams.has("CMCD"))return;let et=((ce=(ie=R.searchParams.get("CMCD"))==null?void 0:ie.split(","))!=null?ce:[]).filter(ue=>ue.startsWith("sid")||ue.startsWith("cid")).join(",");R.searchParams.set("CMCD",et),L.open("GET",R)},...i,...l,...f,...c})}},qe=e=>e===g.LIVE?{backBufferLength:8}:{},Ye=e=>{let{drmToken:t,src:n,playbackId:a=ne(n)}=e;return!t||!a?{}:{emeEnabled:!0,drmSystems:{"com.apple.fps":{licenseUrl:w(e,"fairplay"),serverCertificateUrl:oe(e,"fairplay")},"com.widevine.alpha":{licenseUrl:w(e,"widevine")},"com.microsoft.playready":{licenseUrl:w(e,"playready")}}}},ze=async e=>await(await fetch(e)).arrayBuffer(),Xe=async(e,t)=>{let a=await(await fetch(t,{method:"POST",headers:{"Content-type":"application/octet-stream"},body:e})).arrayBuffer();return new Uint8Array(a)},Ge=(e,t)=>{y(t,"encrypted",async a=>{try{let r=a.initDataType;if(r!=="skd"){console.error(`Received unexpected initialization data type "${r}"`);return}if(!t.mediaKeys){let d=await(await navigator.requestMediaKeySystemAccess("com.apple.fps",[{initDataTypes:[r],videoCapabilities:[{contentType:"application/vnd.apple.mpegurl",robustness:""}],distinctiveIdentifier:"not-allowed",persistentState:"not-allowed",sessionTypes:["temporary"]}])).createMediaKeys(),i=await ze(oe(e,"fairplay"));await d.setServerCertificate(i),await t.setMediaKeys(d)}let o=a.initData;if(o==null){console.error(`Could not start encrypted playback due to missing initData in ${a.type} event`);return}let s=t.mediaKeys.createSession();s.generateRequest(r,o);let c=await new Promise(u=>{s.addEventListener("message",d=>{u(d.message)},{once:!0})}),p=await Xe(c,w(e,"fairplay"));return await s.update(p),s}catch(r){console.error(`Could not start encrypted playback due to exception "${r}"`)}})},w=({playbackId:e,drmToken:t,customDomain:n=k},a)=>`https://license.${n.toLocaleLowerCase().endsWith(k)?n:k}/license/${a}/${e}?token=${t}`,oe=({playbackId:e,drmToken:t,customDomain:n=k},a)=>`https://license.${n.toLocaleLowerCase().endsWith(k)?n:k}/appcert/${a}/${e}?token=${t}`,se=({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(k)||!!n&&r.includes(n.toLocaleLowerCase())},je=(e,t,n)=>{var s;let{envKey:a,disableTracking:r}=e,o=se(e);if(!r&&(a||o)){let{playerInitTime:c,playerSoftwareName:p,playerSoftwareVersion:u,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=E=>typeof E.player_error_code=="string"?!1:typeof e.errorTranslator=="function"?e.errorTranslator(E):E;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:u,player_init_time:c,...f}})}},Je=(e,t,n)=>{var u;let a=Be(e,t),{src:r}=e,o=()=>{t.ended||!We(t,n)||(ae(t,n)?t.currentTime=t.buffered.end(t.buffered.length-1):t.dispatchEvent(new Event("ended")))},s,c,p=()=>{var l,f;let d=(l=W(t))==null?void 0:l.start(0),i=(f=W(t))==null?void 0:f.end(0);(c!==i||s!==d)&&t.dispatchEvent(new CustomEvent("seekablechange",{composed:!0})),s=d,c=i};if(y(t,"durationchange",p),t&&a){let d=A(e);if(typeof r=="string"){let i=()=>{if(ee(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=()=>{F(r,t,d).then(i),t.removeEventListener("loadedmetadata",f)},f=()=>{F(r,t,d).then(i),t.removeEventListener("play",l)};y(t,"play",l,{once:!0}),y(t,"loadedmetadata",f,{once:!0})}else F(r,t,d).then(i);e.drmToken&&Ge(e,t),t.setAttribute("src",r),e.startTime&&(((u=M.get(t))!=null?u:{}).startTime=e.startTime,t.addEventListener("durationchange",Qe,{once:!0}))}else t.removeAttribute("src");t.addEventListener("error",Ze),t.addEventListener("error",te),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||Ue(t.currentTime,t.duration)&&(t.currentTime=t.seekable.start(0))})}else n&&r?(n.once(T.Events.LEVEL_LOADED,(d,i)=>{_e(i.details,t,n),p(),ee(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",te),y(t,"waiting",o),Me(e,n),ve(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 Qe(e){var a;let t=e.target,n=(a=M.get(t))==null?void 0:a.startTime;if(n&&fe(t.seekable,t.duration,n)){let r=t.preload==="auto";r&&(t.preload="none"),t.currentTime=n,r&&(t.preload="auto")}}async function Ze(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 te(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

@@ -6,7 +6,7 @@ /// <reference types="mux-embed/dist/types/mux-embed" />

import { MediaError } from './errors';
import { addTextTrack, removeTextTrack, addCuePoints, getCuePoints, getActiveCuePoint, setupCuePoints, getCuePointsTrack } from './text-tracks';
import { addTextTrack, removeTextTrack, getTextTrack, addCuePoints, getCuePoints, getActiveCuePoint, setupCuePoints, addChapters, getChapters, getActiveChapter, setupChapters } from './text-tracks';
import { getStartDate, getCurrentPdt } from './pdt';
import { ValueOf, PlaybackCore, MuxMediaProps, MuxMediaPropsInternal, MaxResolutionValue, MinResolutionValue, RenditionOrderValue } from './types';
import { StreamTypes, MediaTypes } from './types';
export { mux, Hls, MediaError, addTextTrack, removeTextTrack, addCuePoints, getCuePoints, getActiveCuePoint, getCuePointsTrack, setupCuePoints, getStartDate, getCurrentPdt, };
export { mux, Hls, MediaError, addTextTrack, removeTextTrack, getTextTrack, addCuePoints, getCuePoints, getActiveCuePoint, setupCuePoints, addChapters, getChapters, getActiveChapter, setupChapters, getStartDate, getCurrentPdt, };
export * from './types';

@@ -48,2 +48,4 @@ export declare const getMediaPlaylistLinesFromMultivariantPlaylistSrc: (src: string) => Promise<string[]>;

renditionOrder: RenditionOrderValue;
programStartTime: number;
programEndTime: number;
tokens: Partial<{

@@ -56,3 +58,4 @@ 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 toPlaybackIdFromSrc: (src: string | undefined) => string | undefined;
export declare const getError: (mediaEl: HTMLMediaElement) => globalThis.MediaError | (globalThis.MediaError & MediaError) | null | undefined;

@@ -76,6 +79,29 @@ export declare const getStreamType: (mediaEl: HTMLMediaElement) => ValueOf<StreamTypes>;

export declare const teardown: (mediaEl?: HTMLMediaElement | null, core?: PlaybackCore) => void;
export declare const setupHls: (props: Partial<Pick<MuxMediaPropsInternal, 'debug' | 'streamType' | 'type' | 'startTime' | 'metadata' | 'preferCmcd' | '_hlsConfig'>>, mediaEl: Pick<HTMLMediaElement, 'canPlayType'>) => Hls | undefined;
export declare const setupHls: (props: Partial<Pick<MuxMediaPropsInternal, 'debug' | 'streamType' | 'type' | 'startTime' | 'metadata' | 'preferCmcd' | '_hlsConfig' | 'drmToken'>>, mediaEl: Pick<HTMLMediaElement, 'canPlayType'>) => Hls | undefined;
export declare const getStreamTypeConfig: (streamType?: ValueOf<StreamTypes>) => {};
export declare const getDRMConfig: (props: Partial<Pick<MuxMediaPropsInternal, 'src' | 'playbackId' | 'drmToken' | 'customDomain'>>) => {
emeEnabled?: undefined;
drmSystems?: undefined;
} | {
emeEnabled: boolean;
drmSystems: {
'com.apple.fps': {
licenseUrl: string;
serverCertificateUrl: string;
};
'com.widevine.alpha': {
licenseUrl: string;
};
'com.microsoft.playready': {
licenseUrl: string;
};
};
};
export declare const getAppCertificate: (appCertificateUrl: string) => Promise<ArrayBuffer>;
export declare const getLicenseKey: (message: ArrayBuffer, licenseServerUrl: string) => Promise<Uint8Array>;
export declare const setupNativeFairplayDRM: (props: Partial<Pick<MuxMediaPropsInternal, 'playbackId' | 'drmToken' | 'customDomain'>>, mediaEl: HTMLMediaElement) => void;
export declare const toLicenseKeyURL: ({ playbackId, drmToken: token, customDomain, }: Partial<Pick<MuxMediaPropsInternal, 'playbackId' | 'drmToken' | 'customDomain'>>, scheme: 'widevine' | 'playready' | 'fairplay') => string;
export declare const toAppCertURL: ({ playbackId, drmToken: token, customDomain, }: Partial<Pick<MuxMediaPropsInternal, 'playbackId' | 'drmToken' | 'customDomain'>>, scheme: 'widevine' | 'playready' | 'fairplay') => string;
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' | '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;
export declare const loadMedia: (props: Partial<Pick<MuxMediaProps, 'preferPlayback' | 'src' | 'type' | 'startTime' | 'streamType' | 'autoplay' | 'playbackId' | 'drmToken' | 'customDomain'>>, 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;
import Hls from './hls';
import { CuePoint } from './types';
import { CuePoint, Chapter } from './types';
type Config = {
label: string;
};
export declare function setupTextTracks(mediaEl: HTMLMediaElement, hls: Pick<Hls, 'on' | 'once' | 'subtitleTracks' | 'subtitleTrack'>): void;
export declare function addTextTrack(mediaEl: HTMLMediaElement, kind: TextTrackKind, label: string, lang?: string, id?: string): TextTrack;
export declare function removeTextTrack(mediaEl: HTMLMediaElement, track: TextTrack): void;
export type CuePointsConfig = {
label: string;
};
export declare const DefaultCuePointsConfig: CuePointsConfig;
export declare const getCuePointsTrack: (mediaEl: HTMLMediaElement, { label }?: CuePointsConfig) => TextTrack | undefined;
export declare function addCuePoints<T>(mediaEl: HTMLMediaElement, cuePoints: CuePoint<T>[], cuePointsConfig?: CuePointsConfig): Promise<TextTrack>;
export declare function getCuePoints(mediaEl: HTMLMediaElement, cuePointsConfig?: CuePointsConfig): {
export declare function getTextTrack(mediaEl: HTMLMediaElement, label: string, kind: TextTrackKind): TextTrack | undefined;
export declare function addCuesToTextTrack<T = any>(mediaEl: HTMLMediaElement, cues: CuePoint<T>[] | Chapter[], label: string, kind: TextTrackKind): Promise<TextTrack>;
export declare const DefaultCuePointsConfig: Config;
export declare function addCuePoints<T>(mediaEl: HTMLMediaElement, cuePoints: CuePoint<T>[], cuePointsConfig?: Config): Promise<TextTrack>;
export declare function getCuePoints(mediaEl: HTMLMediaElement, cuePointsConfig?: Config): {
time: number;
value: any;
}[];
export declare function getActiveCuePoint(mediaEl: HTMLMediaElement, cuePointsConfig?: CuePointsConfig): {
export declare function getActiveCuePoint(mediaEl: HTMLMediaElement, cuePointsConfig?: Config): {
time: number;
value: any;
} | undefined;
export declare function setupCuePoints(mediaEl: HTMLMediaElement, cuePointsConfig?: CuePointsConfig): Promise<unknown>;
export declare function setupCuePoints(mediaEl: HTMLMediaElement, cuePointsConfig?: Config): Promise<unknown>;
export declare const DefaultChaptersConfig: Config;
export declare function addChapters(mediaEl: HTMLMediaElement, chapters: Chapter[], chaptersConfig?: Config): Promise<TextTrack>;
export declare function getChapters(mediaEl: HTMLMediaElement, chaptersConfig?: Config): {
startTime: number;
endTime: number;
value: string;
}[];
export declare function getActiveChapter(mediaEl: HTMLMediaElement, chaptersConfig?: Config): {
startTime: number;
endTime: number;
value: string;
} | undefined;
export declare function setupChapters(mediaEl: HTMLMediaElement, chaptersConfig?: Config): Promise<unknown>;
export {};

@@ -57,6 +57,12 @@ /// <reference types="mux-embed/dist/types/mux-embed" />

export declare const allMediaTypes: MediaTypes[];
export type CuePoint<T = any> = {
type CueLike<T = any> = {
startTime: number;
endTime?: number;
value: T;
};
export type CuePoint<T = any> = CueLike<T> | {
time: number;
value: T;
};
export type Chapter = CueLike<string>;
export declare const MaxResolution: {

@@ -91,2 +97,3 @@ readonly upTo720p: "720p";

disableTracking: boolean;
drmToken?: string;
envKey: MetaData['env_key'];

@@ -103,2 +110,4 @@ error?: HTMLMediaElement['error'] | MediaError;

preferPlayback: ValueOf<PlaybackTypes> | undefined;
programStartTime: number;
programEndTime: number;
renditionOrder: RenditionOrderValue;

@@ -109,2 +118,3 @@ startTime: Hls['config']['startPosition'];

tokens: Partial<{
drm: string;
playback: string;

@@ -111,0 +121,0 @@ storyboard: string;

@@ -6,7 +6,7 @@ /// <reference types="mux-embed/dist/types/mux-embed" />

import { MediaError } from './errors';
import { addTextTrack, removeTextTrack, addCuePoints, getCuePoints, getActiveCuePoint, setupCuePoints, getCuePointsTrack } from './text-tracks';
import { addTextTrack, removeTextTrack, getTextTrack, addCuePoints, getCuePoints, getActiveCuePoint, setupCuePoints, addChapters, getChapters, getActiveChapter, setupChapters } from './text-tracks';
import { getStartDate, getCurrentPdt } from './pdt';
import type { ValueOf, PlaybackCore, MuxMediaProps, MuxMediaPropsInternal, MaxResolutionValue, MinResolutionValue, RenditionOrderValue } from './types';
import { StreamTypes, MediaTypes } from './types';
export { mux, Hls, MediaError, addTextTrack, removeTextTrack, addCuePoints, getCuePoints, getActiveCuePoint, getCuePointsTrack, setupCuePoints, getStartDate, getCurrentPdt, };
export { mux, Hls, MediaError, addTextTrack, removeTextTrack, getTextTrack, addCuePoints, getCuePoints, getActiveCuePoint, setupCuePoints, addChapters, getChapters, getActiveChapter, setupChapters, getStartDate, getCurrentPdt, };
export * from './types';

@@ -48,2 +48,4 @@ export declare const getMediaPlaylistLinesFromMultivariantPlaylistSrc: (src: string) => Promise<string[]>;

renditionOrder: RenditionOrderValue;
programStartTime: number;
programEndTime: number;
tokens: Partial<{

@@ -56,3 +58,4 @@ 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 toPlaybackIdFromSrc: (src: string | undefined) => string | undefined;
export declare const getError: (mediaEl: HTMLMediaElement) => globalThis.MediaError | (globalThis.MediaError & MediaError) | null | undefined;

@@ -76,6 +79,29 @@ export declare const getStreamType: (mediaEl: HTMLMediaElement) => ValueOf<StreamTypes>;

export declare const teardown: (mediaEl?: HTMLMediaElement | null, core?: PlaybackCore) => void;
export declare const setupHls: (props: Partial<Pick<MuxMediaPropsInternal, 'debug' | 'streamType' | 'type' | 'startTime' | 'metadata' | 'preferCmcd' | '_hlsConfig'>>, mediaEl: Pick<HTMLMediaElement, 'canPlayType'>) => Hls | undefined;
export declare const setupHls: (props: Partial<Pick<MuxMediaPropsInternal, 'debug' | 'streamType' | 'type' | 'startTime' | 'metadata' | 'preferCmcd' | '_hlsConfig' | 'drmToken'>>, mediaEl: Pick<HTMLMediaElement, 'canPlayType'>) => Hls | undefined;
export declare const getStreamTypeConfig: (streamType?: ValueOf<StreamTypes>) => {};
export declare const getDRMConfig: (props: Partial<Pick<MuxMediaPropsInternal, 'src' | 'playbackId' | 'drmToken' | 'customDomain'>>) => {
emeEnabled?: undefined;
drmSystems?: undefined;
} | {
emeEnabled: boolean;
drmSystems: {
'com.apple.fps': {
licenseUrl: string;
serverCertificateUrl: string;
};
'com.widevine.alpha': {
licenseUrl: string;
};
'com.microsoft.playready': {
licenseUrl: string;
};
};
};
export declare const getAppCertificate: (appCertificateUrl: string) => Promise<ArrayBuffer>;
export declare const getLicenseKey: (message: ArrayBuffer, licenseServerUrl: string) => Promise<Uint8Array>;
export declare const setupNativeFairplayDRM: (props: Partial<Pick<MuxMediaPropsInternal, 'playbackId' | 'drmToken' | 'customDomain'>>, mediaEl: HTMLMediaElement) => void;
export declare const toLicenseKeyURL: ({ playbackId, drmToken: token, customDomain, }: Partial<Pick<MuxMediaPropsInternal, 'playbackId' | 'drmToken' | 'customDomain'>>, scheme: 'widevine' | 'playready' | 'fairplay') => string;
export declare const toAppCertURL: ({ playbackId, drmToken: token, customDomain, }: Partial<Pick<MuxMediaPropsInternal, 'playbackId' | 'drmToken' | 'customDomain'>>, scheme: 'widevine' | 'playready' | 'fairplay') => string;
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' | '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;
export declare const loadMedia: (props: Partial<Pick<MuxMediaProps, 'preferPlayback' | 'src' | 'type' | 'startTime' | 'streamType' | 'autoplay' | 'playbackId' | 'drmToken' | 'customDomain'>>, 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;
import Hls from './hls';
import { CuePoint } from './types';
import { CuePoint, Chapter } from './types';
type Config = {
label: string;
};
export declare function setupTextTracks(mediaEl: HTMLMediaElement, hls: Pick<Hls, 'on' | 'once' | 'subtitleTracks' | 'subtitleTrack'>): void;
export declare function addTextTrack(mediaEl: HTMLMediaElement, kind: TextTrackKind, label: string, lang?: string, id?: string): TextTrack;
export declare function removeTextTrack(mediaEl: HTMLMediaElement, track: TextTrack): void;
export type CuePointsConfig = {
label: string;
};
export declare const DefaultCuePointsConfig: CuePointsConfig;
export declare const getCuePointsTrack: (mediaEl: HTMLMediaElement, { label }?: CuePointsConfig) => TextTrack | undefined;
export declare function addCuePoints<T>(mediaEl: HTMLMediaElement, cuePoints: CuePoint<T>[], cuePointsConfig?: CuePointsConfig): Promise<TextTrack>;
export declare function getCuePoints(mediaEl: HTMLMediaElement, cuePointsConfig?: CuePointsConfig): {
export declare function getTextTrack(mediaEl: HTMLMediaElement, label: string, kind: TextTrackKind): TextTrack | undefined;
export declare function addCuesToTextTrack<T = any>(mediaEl: HTMLMediaElement, cues: CuePoint<T>[] | Chapter[], label: string, kind: TextTrackKind): Promise<TextTrack>;
export declare const DefaultCuePointsConfig: Config;
export declare function addCuePoints<T>(mediaEl: HTMLMediaElement, cuePoints: CuePoint<T>[], cuePointsConfig?: Config): Promise<TextTrack>;
export declare function getCuePoints(mediaEl: HTMLMediaElement, cuePointsConfig?: Config): {
time: number;
value: any;
}[];
export declare function getActiveCuePoint(mediaEl: HTMLMediaElement, cuePointsConfig?: CuePointsConfig): {
export declare function getActiveCuePoint(mediaEl: HTMLMediaElement, cuePointsConfig?: Config): {
time: number;
value: any;
} | undefined;
export declare function setupCuePoints(mediaEl: HTMLMediaElement, cuePointsConfig?: CuePointsConfig): Promise<unknown>;
export declare function setupCuePoints(mediaEl: HTMLMediaElement, cuePointsConfig?: Config): Promise<unknown>;
export declare const DefaultChaptersConfig: Config;
export declare function addChapters(mediaEl: HTMLMediaElement, chapters: Chapter[], chaptersConfig?: Config): Promise<TextTrack>;
export declare function getChapters(mediaEl: HTMLMediaElement, chaptersConfig?: Config): {
startTime: number;
endTime: number;
value: string;
}[];
export declare function getActiveChapter(mediaEl: HTMLMediaElement, chaptersConfig?: Config): {
startTime: number;
endTime: number;
value: string;
} | undefined;
export declare function setupChapters(mediaEl: HTMLMediaElement, chaptersConfig?: Config): Promise<unknown>;
export {};

@@ -57,6 +57,12 @@ /// <reference types="mux-embed/dist/types/mux-embed" />

export declare const allMediaTypes: MediaTypes[];
export type CuePoint<T = any> = {
type CueLike<T = any> = {
startTime: number;
endTime?: number;
value: T;
};
export type CuePoint<T = any> = CueLike<T> | {
time: number;
value: T;
};
export type Chapter = CueLike<string>;
export declare const MaxResolution: {

@@ -91,2 +97,3 @@ readonly upTo720p: "720p";

disableTracking: boolean;
drmToken?: string;
envKey: MetaData['env_key'];

@@ -103,2 +110,4 @@ error?: HTMLMediaElement['error'] | MediaError;

preferPlayback: ValueOf<PlaybackTypes> | undefined;
programStartTime: number;
programEndTime: number;
renditionOrder: RenditionOrderValue;

@@ -109,2 +118,3 @@ startTime: Hls['config']['startPosition'];

tokens: Partial<{
drm: string;
playback: string;

@@ -111,0 +121,0 @@ storyboard: string;

{
"name": "@mux/playback-core",
"version": "0.23.1",
"version": "0.24.0-canary.0-367275a",
"description": "Core library for media playback in the browser shared by mux elements",

@@ -77,4 +77,3 @@ "main": "./dist/index.cjs.js",

"typescript": "^4.9.4"
},
"gitHead": "8d3ed8373c8ff4d80af24cddb3c0dda77e867ad3"
}
}

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc