@mux/playback-core
Advanced tools
Comparing version 0.9.1-canary.9-0563c30 to 0.10.0
@@ -1,2 +0,2 @@ | ||
var ie=Object.create;var h=Object.defineProperty;var ce=Object.getOwnPropertyDescriptor;var ue=Object.getOwnPropertyNames;var le=Object.getPrototypeOf,de=Object.prototype.hasOwnProperty;var K=e=>h(e,"__esModule",{value:!0});var pe=(e,t)=>{K(e);for(var r in t)h(e,r,{get:t[r],enumerable:!0})},ye=(e,t,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of ue(t))!de.call(e,n)&&n!=="default"&&h(e,n,{get:()=>t[n],enumerable:!(r=ce(t,n))||r.enumerable});return e},P=e=>ye(K(h(e!=null?ie(le(e)):{},"default",e&&e.__esModule&&"default"in e?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e);var B=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)};var F=(e,t,r)=>(B(e,t,"read from private field"),r?r.call(e):t.get(e)),q=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},Y=(e,t,r,n)=>(B(e,t,"write to private field"),n?n.call(e,r):t.set(e,r),r);pe(exports,{ExtensionMimeTypeMap:()=>g,Hls:()=>T.default,MediaError:()=>u,MimeTypeShorthandMap:()=>R,StreamTypes:()=>L,addTextTrack:()=>C,allMediaTypes:()=>Me,generatePlayerInitTime:()=>Te,getError:()=>Ee,getStreamTypeConfig:()=>ee,getType:()=>N,inferMimeTypeFromURL:()=>j,initialize:()=>xe,isMuxVideoSrc:()=>ne,loadMedia:()=>ae,mux:()=>D.default,removeTextTrack:()=>J,setupAutoplay:()=>X,setupHls:()=>re,setupMux:()=>oe,shorthandKeys:()=>me,teardown:()=>te,toMuxVideoURL:()=>ge,toPlaybackIdParts:()=>Z});if(typeof DocumentFragment=="undefined"){class e{}globalThis.DocumentFragment=e}globalThis.customElements||(globalThis.customElements={get(e){},define(e,t,r){},upgrade(e){},whenDefined(e){return Promise.resolve(globalThis.HTMLElement)}});var k;if(!globalThis.CustomEvent){class e{constructor(r,n={}){q(this,k,void 0);Y(this,k,n==null?void 0:n.detail)}get detail(){F(this,k)}initCustomEvent(r,n,o,a){}}k=new WeakMap,globalThis.CustomEvent=e}if(!globalThis.EventTarget){class e{addEventListener(){}removeEventListener(){}dispatchEvent(r){return!0}}globalThis.EventTarget=e}if(!globalThis.HTMLElement){class e extends EventTarget{}globalThis.HTMLElement=e}if(!globalThis.HTMLVideoElement){class e extends EventTarget{}globalThis.HTMLVideoElement=e}var $,z;if(!(($=globalThis.document)==null?void 0:$.createElement)){let e=(z=globalThis.document)!=null?z:{};e.createElement=function(r,n){return new HTMLElement},globalThis.document=e}var D=P(require("mux-embed")),T=P(require("hls.js"));var w=P(require("hls.js")),I={ANY:"any",MUTED:"muted"},fe=Object.values(I),W=e=>typeof e=="boolean"||typeof e=="string"&&fe.includes(e),X=(e,t,r)=>{let n=!1,o=!1,a=W(t)?t:!!t,c=()=>{e.addEventListener("playing",()=>{n=!0},{once:!0})};if(c(),e.addEventListener("loadstart",()=>{n=!1,c(),O(e,a)},{once:!0}),e.addEventListener("loadedmetadata",()=>{r||(o=!Number.isFinite(e.duration)),O(e,a)},{once:!0}),r&&r.once(w.default.Events.LEVEL_LOADED,(i,l)=>{var d;o=(d=l.details.live)!=null?d:!1}),!a){let i=()=>{!o||((r==null?void 0:r.liveSyncPosition)?e.currentTime=r.liveSyncPosition:Number.isFinite(e.seekable.end(0))&&(e.currentTime=e.seekable.end(0)))};e.addEventListener("play",()=>{r&&e.preload==="metadata"?r.once(w.default.Events.LEVEL_UPDATED,i):r&&i()},{once:!0})}return i=>{n||(a=W(i)?i:!!i,O(e,a))}},O=(e,t)=>{if(!t)return;let r=e.muted,n=()=>e.muted=r;switch(t){case I.ANY:e.play().catch(o=>{e.muted=!0,e.play().catch(n)});break;case I.MUTED:e.muted=!0,e.play().catch(n);break;default:e.play().catch(()=>{});break}};var E=class extends Error{constructor(t,r=E.MEDIA_ERR_CUSTOM,n){super(t);var o;this.name="MediaError",this.code=r,this.fatal=n!=null?n:r>=E.MEDIA_ERR_NETWORK&&r<=E.MEDIA_ERR_ENCRYPTED,this.message||(this.message=(o=E.defaultMessages[this.code])!=null?o:"")}},u=E;u.MEDIA_ERR_ABORTED=1,u.MEDIA_ERR_NETWORK=2,u.MEDIA_ERR_DECODE=3,u.MEDIA_ERR_SRC_NOT_SUPPORTED=4,u.MEDIA_ERR_ENCRYPTED=5,u.MEDIA_ERR_CUSTOM=100,u.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=P(require("hls.js"));function G(e,t){t.on(x.default.Events.NON_NATIVE_TEXT_TRACKS_FOUND,(o,{tracks:a})=>{a.forEach(c=>{var l;let s=(l=c.subtitleTrack)!=null?l:c.closedCaptions,i=t.subtitleTracks.findIndex(({lang:d,name:y,type:f})=>d==(s==null?void 0:s.lang)&&y===c.label&&f.toLowerCase()===c.kind);C(e,c.kind,c.label,s==null?void 0:s.lang,`${c.kind}${i}`)})});let r=()=>{var c;if(!t.subtitleTracks.length)return;let o=Array.from(e.textTracks).find(s=>s.id&&s.mode==="showing"&&["subtitles","captions"].includes(s.kind)),a=`${(c=t.subtitleTracks[t.subtitleTrack])==null?void 0:c.type.toLowerCase()}${t.subtitleTrack}`;if(o&&(t.subtitleTrack<0||(o==null?void 0:o.id)!==a)){let s=t.subtitleTracks.findIndex(({lang:i,name:l,type:d})=>i==o.language&&l===o.label&&d.toLowerCase()===o.kind);t.subtitleTrack=s}o&&(o==null?void 0:o.id)===a&&o.cues&&Array.from(o.cues).forEach(s=>{o.addCue(s)})};e.textTracks.addEventListener("change",r),t.on(x.default.Events.CUES_PARSED,(o,{track:a,type:c,cues:s})=>{let i=e.textTracks.getTrackById(a);if(!i)return;let l=i.mode==="disabled";l&&(i.mode="hidden"),s.forEach(d=>{var y;((y=i.cues)==null?void 0:y.getCueById(d.id))||i.addCue(d)}),l&&(i.mode="disabled")}),t.on(x.default.Events.DESTROYING,()=>{e.textTracks.removeEventListener("change",r),e.querySelectorAll("track[data-removeondestroy]").forEach(a=>{a.remove()})});let n=()=>{Array.from(e.textTracks).forEach(o=>{var a,c;if(!["subtitles","caption"].includes(o.kind)&&o.label==="thumbnails"){if(!((a=o.cues)==null?void 0:a.length)){let s=e.querySelector('track[label="thumbnails"]'),i=(c=s==null?void 0:s.getAttribute("src"))!=null?c:"";s==null||s.removeAttribute("src"),setTimeout(()=>{s==null||s.setAttribute("src",i)},0)}o.mode!=="hidden"&&(o.mode="hidden")}})};t.once(x.default.Events.MANIFEST_LOADED,n),t.once(x.default.Events.MEDIA_ATTACHED,n)}function C(e,t,r,n,o){let a=document.createElement("track");return a.kind=t,a.label=r,n&&(a.srclang=n),o&&(a.id=o),a.track.mode="disabled",a.setAttribute("data-removeondestroy",""),e.append(a),a.track}function J(e,t){let r=Array.prototype.find.call(e.querySelectorAll("track"),n=>n.track===t);r==null||r.remove()}var V=(e,t)=>e in t;var Q="mux.com",Te=()=>D.default.utils.now(),L={VOD:"on-demand",ON_DEMAND:"on-demand",LIVE:"live",LL_LIVE:"ll-live",DVR:"live:dvr",LL_DVR:"ll-live:dvr"},g={M3U8:"application/vnd.apple.mpegurl",MP4:"video/mp4"},R={HLS:g.M3U8},me=Object.keys(R),Me=[...Object.values(g),"hls","HLS"],Z=e=>{let t=e.indexOf("?");if(t<0)return[e];let r=e.slice(0,t),n=e.slice(t);return[r,n]},ge=(e,{domain:t=Q}={})=>{if(!e)return;let[r,n=""]=Z(e);return`https://stream.${t}/${r}.m3u8${n}`},j=e=>{let t="";try{t=new URL(e).pathname}catch{console.error("invalid url")}let r=t.lastIndexOf(".");if(r<0)return"";let o=t.slice(r+1).toUpperCase();return V(o,g)?g[o]:""},N=e=>{let t=e.type;if(t){let n=t.toUpperCase();return V(n,R)?R[n]:t}let{src:r}=e;return r?j(r):""},ee=e=>{if([L.LIVE,L.LL_LIVE].includes(e)){let t={backBufferLength:12};return e===L.LL_LIVE?{...t,maxFragLookUpTolerance:.001}:t}return{}},H=new WeakMap,Ee=e=>{var t;return(t=H.get(e))==null?void 0:t.error},te=(e,t)=>{t&&(t.detachMedia(),t.destroy()),(e==null?void 0:e.mux)&&!e.mux.deleted&&(e.mux.destroy(),e.mux),e&&(e.removeEventListener("error",se),e.removeEventListener("error",U),H.delete(e))},re=(e,t)=>{var b,v,A;let{debug:r,preferMse:n,streamType:o,startTime:a=-1}=e,c=N(e),s=c===g.M3U8,i=!c||((b=t==null?void 0:t.canPlayType(c))!=null?b:!0),l=T.default.isSupported(),f=((A=(v=window==null?void 0:window.navigator)==null?void 0:v.userAgent)!=null?A:"").toLowerCase().indexOf("android")!==-1&&o===L.LL_LIVE;if(s&&!(!s||i&&!((n||f)&&l))&&l){let M={backBufferLength:30,renderTextTracksNatively:!1,liveDurationInfinity:!0},p=ee(o);return new T.default({debug:r,startPosition:a,...M,...p})}},ne=({playbackId:e,src:t,customDomain:r})=>{if(e)return!0;if(typeof t!="string")return!1;let n=new URL(t).hostname.toLocaleLowerCase();return n.includes(Q)||!!r&&n.includes(r.toLocaleLowerCase())},oe=(e,t,r)=>{let{envKey:n}=e,o=ne(e);if((n||o)&&t){let{playerInitTime:a,playerSoftwareName:c,playerSoftwareVersion:s,beaconCollectionDomain:i,metadata:l,debug:d}=e,y=f=>typeof f.player_error_code=="string"?!1:typeof e.errorTranslator=="function"?e.errorTranslator(f):f;D.default.monitor(t,{debug:d,beaconCollectionDomain:i,hlsjs:r,Hls:r?T.default:void 0,automaticErrorTracking:!1,errorTranslator:y,data:{...n?{env_key:n}:{},player_software_name:c,player_software_version:s,player_init_time:a,...l}})}},ae=(e,t,r)=>{var b,v,A;if(!t){console.warn("attempting to load media before mediaEl exists");return}let{preferMse:n,streamType:o}=e,a=N(e),c=a===g.M3U8,s=!a||((b=t==null?void 0:t.canPlayType(a))!=null?b:!0),i=T.default.isSupported(),y=((A=(v=window==null?void 0:window.navigator)==null?void 0:v.userAgent)!=null?A:"").toLowerCase().indexOf("android")!==-1&&o===L.LL_LIVE,f=!c||s&&!((n||y)&&i),{src:m}=e;if(t&&s&&f){if(typeof m=="string"){let{startTime:M}=e;if(t.setAttribute("src",m),M){let p=({target:_})=>{_.currentTime=M,_.removeEventListener("loadedmetadata",p)};t.addEventListener("loadedmetadata",p)}}else t.removeAttribute("src");t.addEventListener("error",se),t.addEventListener("error",U)}else if(r&&m){switch(r.on(T.default.Events.ERROR,(M,p)=>{let _={[T.default.ErrorTypes.NETWORK_ERROR]:u.MEDIA_ERR_NETWORK,[T.default.ErrorTypes.MEDIA_ERROR]:u.MEDIA_ERR_DECODE},S=new u("",_[p.type]);S.fatal=p.fatal,S.data=p,t.dispatchEvent(new CustomEvent("error",{detail:S}))}),t.addEventListener("error",U),G(t,r),t.preload){case"none":t.addEventListener("play",()=>r.loadSource(m),{once:!0});break;case"metadata":let M=r.config.maxBufferLength,p=r.config.maxBufferSize;r.config.maxBufferLength=1,r.config.maxBufferSize=1,t.addEventListener("play",()=>{r.config.maxBufferLength=M,r.config.maxBufferSize=p},{once:!0}),r.loadSource(m);break;default:r.loadSource(m)}r.attachMedia(t)}else 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.")};async function se(e){if(!e.isTrusted)return;e.stopImmediatePropagation();let t=e.target;if(!(t==null?void 0:t.error))return;let{message:r,code:n}=t.error,o=new u(r,n);if(t.src&&(n!==u.MEDIA_ERR_DECODE||n!==void 0)){let{status:a}=await fetch(t.src);o.data={response:{code:a}}}t.dispatchEvent(new CustomEvent("error",{detail:o}))}function U(e){var o;if(!(e instanceof CustomEvent)||!(e.detail instanceof u))return;let t=e.target,r=e.detail;if(!r||!r.fatal)return;let n=H.get(t);n&&(n.error=r),(o=t.mux)==null||o.emit("error",{player_error_code:r.code,player_error_message:r.message})}var xe=(e,t,r)=>{te(t,r),H.set(t,{});let n=re(e,t);return oe(e,t,n),ae(e,t,n),n}; | ||
var ee=Object.create;var _=Object.defineProperty;var te=Object.getOwnPropertyDescriptor;var re=Object.getOwnPropertyNames;var ne=Object.getPrototypeOf,oe=Object.prototype.hasOwnProperty;var U=e=>_(e,"__esModule",{value:!0});var ae=(e,t)=>{U(e);for(var r in t)_(e,r,{get:t[r],enumerable:!0})},se=(e,t,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of re(t))!oe.call(e,n)&&n!=="default"&&_(e,n,{get:()=>t[n],enumerable:!(r=te(t,n))||r.enumerable});return e},P=e=>se(U(_(e!=null?ee(ne(e)):{},"default",e&&e.__esModule&&"default"in e?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e);ae(exports,{ExtensionMimeTypeMap:()=>x,Hls:()=>T.default,MediaError:()=>u,MimeTypeShorthandMap:()=>R,StreamTypes:()=>k,addTextTrack:()=>w,allMediaTypes:()=>pe,generatePlayerInitTime:()=>ce,getError:()=>le,getStreamTypeConfig:()=>W,getType:()=>V,inferMimeTypeFromURL:()=>z,initialize:()=>ye,isMuxVideoSrc:()=>J,loadMedia:()=>Z,mux:()=>D.default,removeTextTrack:()=>Y,setupAutoplay:()=>B,setupHls:()=>G,setupMux:()=>Q,shorthandKeys:()=>ue,teardown:()=>X,toMuxVideoURL:()=>de,toPlaybackIdParts:()=>F});var D=P(require("mux-embed")),T=P(require("hls.js"));var H=P(require("hls.js")),h={ANY:"any",MUTED:"muted"},ie=Object.values(h),K=e=>typeof e=="boolean"||typeof e=="string"&&ie.includes(e),B=(e,t,r)=>{let n=!1,o=!1,a=K(t)?t:!!t,c=()=>{e.addEventListener("playing",()=>{n=!0},{once:!0})};if(c(),e.addEventListener("loadstart",()=>{n=!1,c(),O(e,a)},{once:!0}),e.addEventListener("loadedmetadata",()=>{r||(o=!Number.isFinite(e.duration)),O(e,a)},{once:!0}),r&&r.once(H.default.Events.LEVEL_LOADED,(i,p)=>{var d;o=(d=p.details.live)!=null?d:!1}),!a){let i=()=>{!o||((r==null?void 0:r.liveSyncPosition)?e.currentTime=r.liveSyncPosition:Number.isFinite(e.seekable.end(0))&&(e.currentTime=e.seekable.end(0)))};e.addEventListener("play",()=>{r&&e.preload==="metadata"?r.once(H.default.Events.LEVEL_UPDATED,i):r&&i()},{once:!0})}return i=>{n||(a=K(i)?i:!!i,O(e,a))}},O=(e,t)=>{if(!t)return;let r=e.muted,n=()=>e.muted=r;switch(t){case h.ANY:e.play().catch(o=>{e.muted=!0,e.play().catch(n)});break;case h.MUTED:e.muted=!0,e.play().catch(n);break;default:e.play().catch(()=>{});break}};var g=class extends Error{constructor(t,r=g.MEDIA_ERR_CUSTOM,n){super(t);var o;this.name="MediaError",this.code=r,this.fatal=n!=null?n:r>=g.MEDIA_ERR_NETWORK&&r<=g.MEDIA_ERR_ENCRYPTED,this.message||(this.message=(o=g.defaultMessages[this.code])!=null?o:"")}},u=g;u.MEDIA_ERR_ABORTED=1,u.MEDIA_ERR_NETWORK=2,u.MEDIA_ERR_DECODE=3,u.MEDIA_ERR_SRC_NOT_SUPPORTED=4,u.MEDIA_ERR_ENCRYPTED=5,u.MEDIA_ERR_CUSTOM=100,u.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 L=P(require("hls.js"));function q(e,t){t.on(L.default.Events.NON_NATIVE_TEXT_TRACKS_FOUND,(o,{tracks:a})=>{a.forEach(c=>{var p;let s=(p=c.subtitleTrack)!=null?p:c.closedCaptions,i=t.subtitleTracks.findIndex(({lang:d,name:y,type:f})=>d==(s==null?void 0:s.lang)&&y===c.label&&f.toLowerCase()===c.kind);w(e,c.kind,c.label,s==null?void 0:s.lang,`${c.kind}${i}`)})});let r=()=>{var c;if(!t.subtitleTracks.length)return;let o=Array.from(e.textTracks).find(s=>s.id&&s.mode==="showing"&&["subtitles","captions"].includes(s.kind)),a=`${(c=t.subtitleTracks[t.subtitleTrack])==null?void 0:c.type.toLowerCase()}${t.subtitleTrack}`;if(o&&(t.subtitleTrack<0||(o==null?void 0:o.id)!==a)){let s=t.subtitleTracks.findIndex(({lang:i,name:p,type:d})=>i==o.language&&p===o.label&&d.toLowerCase()===o.kind);t.subtitleTrack=s}o&&(o==null?void 0:o.id)===a&&o.cues&&Array.from(o.cues).forEach(s=>{o.addCue(s)})};e.textTracks.addEventListener("change",r),t.on(L.default.Events.CUES_PARSED,(o,{track:a,type:c,cues:s})=>{let i=e.textTracks.getTrackById(a);if(!i)return;let p=i.mode==="disabled";p&&(i.mode="hidden"),s.forEach(d=>{var y;((y=i.cues)==null?void 0:y.getCueById(d.id))||i.addCue(d)}),p&&(i.mode="disabled")}),t.on(L.default.Events.DESTROYING,()=>{e.textTracks.removeEventListener("change",r),e.querySelectorAll("track[data-removeondestroy]").forEach(a=>{a.remove()})});let n=()=>{Array.from(e.textTracks).forEach(o=>{var a,c;if(!["subtitles","caption"].includes(o.kind)&&o.label==="thumbnails"){if(!((a=o.cues)==null?void 0:a.length)){let s=e.querySelector('track[label="thumbnails"]'),i=(c=s==null?void 0:s.getAttribute("src"))!=null?c:"";s==null||s.removeAttribute("src"),setTimeout(()=>{s==null||s.setAttribute("src",i)},0)}o.mode!=="hidden"&&(o.mode="hidden")}})};t.once(L.default.Events.MANIFEST_LOADED,n),t.once(L.default.Events.MEDIA_ATTACHED,n)}function w(e,t,r,n,o){let a=document.createElement("track");return a.kind=t,a.label=r,n&&(a.srclang=n),o&&(a.id=o),a.track.mode="disabled",a.setAttribute("data-removeondestroy",""),e.append(a),a.track}function Y(e,t){let r=Array.prototype.find.call(e.querySelectorAll("track"),n=>n.track===t);r==null||r.remove()}var C=(e,t)=>e in t;var $="mux.com",ce=()=>D.default.utils.now(),k={VOD:"on-demand",ON_DEMAND:"on-demand",LIVE:"live",LL_LIVE:"ll-live",DVR:"live:dvr",LL_DVR:"ll-live:dvr"},x={M3U8:"application/vnd.apple.mpegurl",MP4:"video/mp4"},R={HLS:x.M3U8},ue=Object.keys(R),pe=[...Object.values(x),"hls","HLS"],F=e=>{let t=e.indexOf("?");if(t<0)return[e];let r=e.slice(0,t),n=e.slice(t);return[r,n]},de=(e,{domain:t=$}={})=>{if(!e)return;let[r,n=""]=F(e);return`https://stream.${t}/${r}.m3u8${n}`},z=e=>{let t="";try{t=new URL(e).pathname}catch{console.error("invalid url")}let r=t.lastIndexOf(".");if(r<0)return"";let o=t.slice(r+1).toUpperCase();return C(o,x)?x[o]:""},V=e=>{let t=e.type;if(t){let n=t.toUpperCase();return C(n,R)?R[n]:t}let{src:r}=e;return r?z(r):""},W=e=>{if([k.LIVE,k.LL_LIVE].includes(e)){let t={backBufferLength:12};return e===k.LL_LIVE?{...t,maxFragLookUpTolerance:.001}:t}return{}},S=new WeakMap,le=e=>{var t;return(t=S.get(e))==null?void 0:t.error},X=(e,t)=>{t&&(t.detachMedia(),t.destroy()),(e==null?void 0:e.mux)&&!e.mux.deleted&&(e.mux.destroy(),e.mux),e&&(e.removeEventListener("error",j),e.removeEventListener("error",N),S.delete(e))},G=(e,t)=>{var E,v,b;let{debug:r,preferMse:n,streamType:o,startTime:a=-1}=e,c=V(e),s=c===x.M3U8,i=!c||((E=t==null?void 0:t.canPlayType(c))!=null?E:!0),p=T.default.isSupported(),f=((b=(v=window==null?void 0:window.navigator)==null?void 0:v.userAgent)!=null?b:"").toLowerCase().indexOf("android")!==-1;if(s&&!(!s||i&&!((n||f)&&p))&&p){let m={backBufferLength:30,renderTextTracksNatively:!1,liveDurationInfinity:!0},l=W(o);return new T.default({debug:r,startPosition:a,...m,...l})}},J=({playbackId:e,src:t,customDomain:r})=>{if(e)return!0;if(typeof t!="string")return!1;let n=new URL(t).hostname.toLocaleLowerCase();return n.includes($)||!!r&&n.includes(r.toLocaleLowerCase())},Q=(e,t,r)=>{let{envKey:n}=e,o=J(e);if((n||o)&&t){let{playerInitTime:a,playerSoftwareName:c,playerSoftwareVersion:s,beaconCollectionDomain:i,metadata:p,debug:d}=e,y=f=>typeof f.player_error_code=="string"?!1:typeof e.errorTranslator=="function"?e.errorTranslator(f):f;D.default.monitor(t,{debug:d,beaconCollectionDomain:i,hlsjs:r,Hls:r?T.default:void 0,automaticErrorTracking:!1,errorTranslator:y,data:{...n?{env_key:n}:{},player_software_name:c,player_software_version:s,player_init_time:a,...p}})}},Z=(e,t,r)=>{var E,v,b;if(!t){console.warn("attempting to load media before mediaEl exists");return}let{preferMse:n,streamType:o}=e,a=V(e),c=a===x.M3U8,s=!a||((E=t==null?void 0:t.canPlayType(a))!=null?E:!0),i=T.default.isSupported(),y=((b=(v=window==null?void 0:window.navigator)==null?void 0:v.userAgent)!=null?b:"").toLowerCase().indexOf("android")!==-1&&o===k.LL_LIVE,f=!c||s&&!((n||y)&&i),{src:M}=e;if(t&&s&&f){if(typeof M=="string"){let{startTime:m}=e;if(t.setAttribute("src",M),m){let l=({target:A})=>{A.currentTime=m,A.removeEventListener("loadedmetadata",l)};t.addEventListener("loadedmetadata",l)}}else t.removeAttribute("src");t.addEventListener("error",j),t.addEventListener("error",N)}else if(r&&M){switch(r.on(T.default.Events.ERROR,(m,l)=>{let A={[T.default.ErrorTypes.NETWORK_ERROR]:u.MEDIA_ERR_NETWORK,[T.default.ErrorTypes.MEDIA_ERROR]:u.MEDIA_ERR_DECODE},I=new u("",A[l.type]);I.fatal=l.fatal,I.data=l,t.dispatchEvent(new CustomEvent("error",{detail:I}))}),t.addEventListener("error",N),q(t,r),t.preload){case"none":t.addEventListener("play",()=>r.loadSource(M),{once:!0});break;case"metadata":let m=r.config.maxBufferLength,l=r.config.maxBufferSize;r.config.maxBufferLength=1,r.config.maxBufferSize=1,t.addEventListener("play",()=>{r.config.maxBufferLength=m,r.config.maxBufferSize=l},{once:!0}),r.loadSource(M);break;default:r.loadSource(M)}r.attachMedia(t)}else 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.")};async function j(e){if(!e.isTrusted)return;e.stopImmediatePropagation();let t=e.target;if(!(t==null?void 0:t.error))return;let{message:r,code:n}=t.error,o=new u(r,n);if(t.src&&(n!==u.MEDIA_ERR_DECODE||n!==void 0)){let{status:a}=await fetch(t.src);o.data={response:{code:a}}}t.dispatchEvent(new CustomEvent("error",{detail:o}))}function N(e){var o;if(!(e instanceof CustomEvent)||!(e.detail instanceof u))return;let t=e.target,r=e.detail;if(!r||!r.fatal)return;let n=S.get(t);n&&(n.error=r),(o=t.mux)==null||o.emit("error",{player_error_code:r.code,player_error_message:r.message})}var ye=(e,t,r)=>{X(t,r),S.set(t,{});let n=G(e,t);return Q(e,t,n),Z(e,t,n),n}; | ||
//# sourceMappingURL=index.cjs.js.map |
@@ -1,2 +0,1 @@ | ||
import '@mux/polyfills'; | ||
import mux, { Options } from 'mux-embed'; | ||
@@ -3,0 +2,0 @@ import Hls, { HlsConfig } from 'hls.js'; |
@@ -1,2 +0,1 @@ | ||
import '@mux/polyfills'; | ||
import mux, { Options } from 'mux-embed'; | ||
@@ -3,0 +2,0 @@ import Hls, { HlsConfig } from 'hls.js'; |
{ | ||
"name": "@mux/playback-core", | ||
"version": "0.9.1-canary.9-0563c30", | ||
"version": "0.10.0", | ||
"description": "Core library for media playback in the browser shared by mux elements", | ||
@@ -41,6 +41,6 @@ "main": "./dist/index.cjs.js", | ||
"build:iife": "esbuild --metafile=./dist/iife.json src/index.ts --target=es2019 --bundle --sourcemap --format=iife --outfile=./dist/playback-core.js", | ||
"build:types": "tsc --declaration --emitDeclarationOnly --outDir './dist/types' && downlevel-dts ./dist/types ./dist/types-ts3.4 --to=3.4", | ||
"build:types": "tsc --declaration --emitDeclarationOnly --outDir './dist/types'", | ||
"postbuild:types": "downlevel-dts ./dist/types ./dist/types-ts3.4 --to=3.4", | ||
"build": "npm-run-all --parallel build:types 'build:esm -- --minify' 'build:iife -- --minify' 'build:cjs -- --minify' 'build:esm-module -- --minify'", | ||
"prebuild": "yarn clean", | ||
"prepublishOnly": "yarn build", | ||
"create-release-notes": "create-release-notes ./CHANGELOG.md", | ||
@@ -55,9 +55,10 @@ "publish-release": "../../scripts/publish.sh" | ||
"@mux/open-process": "0.1.0", | ||
"@mux/polyfills": "0.1.0", | ||
"downlevel-dts": "^0.9.0", | ||
"esbuild": "^0.13.13", | ||
"npm-run-all": "^4.1.5", | ||
"shared-polyfills": "0.1.0", | ||
"shx": "^0.3.4", | ||
"typescript": "^4.5.2" | ||
} | ||
}, | ||
"gitHead": "505f1e6e74b2caed83d2a54ec9f3660573e4d6e9" | ||
} |
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
4048493
22
3953