@mux/playback-core
Advanced tools
Comparing version 0.9.1-canary.38-6c5a124 to 0.9.1-canary.39-ad43416
@@ -20,3 +20,3 @@ { | ||
"src/index.ts": { | ||
"bytes": 17061, | ||
"bytes": 17023, | ||
"imports": [ | ||
@@ -47,3 +47,3 @@ { | ||
"inputs": {}, | ||
"bytes": 43493 | ||
"bytes": 43436 | ||
}, | ||
@@ -56,3 +56,3 @@ "dist/index.cjs.js": { | ||
"src/index.ts": { | ||
"bytesInOutput": 5302 | ||
"bytesInOutput": 5287 | ||
}, | ||
@@ -72,5 +72,5 @@ "src/autoplay.ts": { | ||
}, | ||
"bytes": 10019 | ||
"bytes": 10004 | ||
} | ||
} | ||
} |
@@ -20,3 +20,3 @@ { | ||
"src/index.ts": { | ||
"bytes": 17061, | ||
"bytes": 17023, | ||
"imports": [ | ||
@@ -47,3 +47,3 @@ { | ||
"inputs": {}, | ||
"bytes": 42606 | ||
"bytes": 42549 | ||
}, | ||
@@ -81,3 +81,3 @@ "dist/index.mjs": { | ||
"src/index.ts": { | ||
"bytesInOutput": 4692 | ||
"bytesInOutput": 4677 | ||
}, | ||
@@ -97,5 +97,5 @@ "src/autoplay.ts": { | ||
}, | ||
"bytes": 9214 | ||
"bytes": 9199 | ||
} | ||
} | ||
} |
@@ -38,3 +38,3 @@ { | ||
"src/index.ts": { | ||
"bytes": 17061, | ||
"bytes": 17023, | ||
"imports": [ | ||
@@ -73,3 +73,3 @@ { | ||
"inputs": {}, | ||
"bytes": 1684516 | ||
"bytes": 1684459 | ||
}, | ||
@@ -88,3 +88,3 @@ "dist/playback-core.js": { | ||
"src/index.ts": { | ||
"bytesInOutput": 4817 | ||
"bytesInOutput": 4801 | ||
}, | ||
@@ -104,5 +104,5 @@ "src/autoplay.ts": { | ||
}, | ||
"bytes": 472374 | ||
"bytes": 472358 | ||
} | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
"use strict";var ne=Object.create;var P=Object.defineProperty;var oe=Object.getOwnPropertyDescriptor;var ae=Object.getOwnPropertyNames;var se=Object.getPrototypeOf,ie=Object.prototype.hasOwnProperty;var ce=(e,t)=>{for(var r in t)P(e,r,{get:t[r],enumerable:!0})},U=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of ae(t))!ie.call(e,o)&&o!==r&&P(e,o,{get:()=>t[o],enumerable:!(n=oe(t,o))||n.enumerable});return e};var R=(e,t,r)=>(r=e!=null?ne(se(e)):{},U(t||!e||!e.__esModule?P(r,"default",{value:e,enumerable:!0}):r,e)),ue=e=>U(P({},"__esModule",{value:!0}),e);var me={};ce(me,{ExtensionMimeTypeMap:()=>M,Hls:()=>f.default,MediaError:()=>u,MimeTypeShorthandMap:()=>D,StreamTypes:()=>A,addTextTrack:()=>O,allMediaTypes:()=>ye,generatePlayerInitTime:()=>de,getError:()=>Te,getStreamTypeConfig:()=>X,getType:()=>N,inferMimeTypeFromURL:()=>W,initialize:()=>Me,isMuxVideoSrc:()=>Q,loadMedia:()=>j,mux:()=>S.default,removeTextTrack:()=>Y,setupAutoplay:()=>B,setupHls:()=>J,setupMux:()=>Z,shorthandKeys:()=>le,teardown:()=>G,toMuxVideoURL:()=>fe,toPlaybackIdParts:()=>z});module.exports=ue(me);var S=R(require("mux-embed")),f=R(require("hls.js"));var H=R(require("hls.js")),w={ANY:"any",MUTED:"muted"},pe=Object.values(w),K=e=>typeof e=="boolean"||typeof e=="string"&&pe.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(),h(e,a)},{once:!0}),e.addEventListener("loadedmetadata",()=>{r||(o=!Number.isFinite(e.duration)),h(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&&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,h(e,a))}},h=(e,t)=>{if(!t)return;let r=e.muted,n=()=>e.muted=r;switch(t){case w.ANY:e.play().catch(o=>{e.muted=!0,e.play().catch(n)});break;case w.MUTED:e.muted=!0,e.play().catch(n);break;default:e.play().catch(()=>{});break}};var x=class extends Error{constructor(r,n=x.MEDIA_ERR_CUSTOM,o){var a;super(r);this.name="MediaError",this.code=n,this.fatal=o!=null?o:n>=x.MEDIA_ERR_NETWORK&&n<=x.MEDIA_ERR_ENCRYPTED,this.message||(this.message=(a=x.defaultMessages[this.code])!=null?a:"")}},u=x;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 g=R(require("hls.js"));function q(e,t){t.on(g.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:l,type:y})=>d==(s==null?void 0:s.lang)&&l===c.label&&y.toLowerCase()===c.kind);O(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(g.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 l;(l=i.cues)!=null&&l.getCueById(d.id)||i.addCue(d)}),p&&(i.mode="disabled")}),t.on(g.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&&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(g.default.Events.MANIFEST_LOADED,n),t.once(g.default.Events.MEDIA_ATTACHED,n)}function O(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;function $(e,t,r){t&&r>t&&(r=t);for(let n=0;n<e.length;n++)if(e.start(n)<=r&&e.end(n)>=r)return!0;return!1}var F="mux.com",de=()=>S.default.utils.now(),A={VOD:"on-demand",ON_DEMAND:"on-demand",LIVE:"live",LL_LIVE:"ll-live",DVR:"live:dvr",LL_DVR:"ll-live:dvr"},M={M3U8:"application/vnd.apple.mpegurl",MP4:"video/mp4"},D={HLS:M.M3U8},le=Object.keys(D),ye=[...Object.values(M),"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]},fe=(e,{domain:t=F}={})=>{if(!e)return;let[r,n=""]=z(e);return`https://stream.${t}/${r}.m3u8${n}`},W=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,M)?M[o]:""},N=e=>{let t=e.type;if(t){let n=t.toUpperCase();return C(n,D)?D[n]:t}let{src:r}=e;return r?W(r):""},X=e=>{if([A.LIVE,A.LL_LIVE].includes(e)){let t={backBufferLength:12};return e===A.LL_LIVE?{...t,maxFragLookUpTolerance:.001}:t}return{}},L=new WeakMap,Te=e=>{var t;return(t=L.get(e))==null?void 0:t.error},G=(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",te),e.removeEventListener("error",V),e.removeEventListener("durationchange",ee),L.delete(e))},J=(e,t)=>{var b,v,E;let{debug:r,preferMse:n,streamType:o,startTime:a=-1}=e,c=N(e),s=c===M.M3U8,i=!c||((b=t==null?void 0:t.canPlayType(c))!=null?b:!0),p=f.default.isSupported(),y=((E=(v=window==null?void 0:window.navigator)==null?void 0:v.userAgent)!=null?E:"").toLowerCase().indexOf("android")!==-1;if(s&&!(!s||i&&!((n||y)&&p))&&p){let k={backBufferLength:30,renderTextTracksNatively:!1,liveDurationInfinity:!0},_=X(o);return new f.default({debug:r,startPosition:a,...k,..._})}},Q=({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(F)||!!r&&n.includes(r.toLocaleLowerCase())},Z=(e,t,r)=>{let{envKey:n}=e,o=Q(e);if((n||o)&&t){let{playerInitTime:a,playerSoftwareName:c,playerSoftwareVersion:s,beaconCollectionDomain:i,metadata:p,debug:d}=e,l=y=>typeof y.player_error_code=="string"?!1:typeof e.errorTranslator=="function"?e.errorTranslator(y):y;S.default.monitor(t,{debug:d,beaconCollectionDomain:i,hlsjs:r,Hls:r?f.default:void 0,automaticErrorTracking:!1,errorTranslator:l,data:{...n?{env_key:n}:{},player_software_name:c,player_software_version:s,player_init_time:a,...p}})}},j=(e,t,r)=>{var b,v,E,k;if(!t){console.warn("attempting to load media before mediaEl exists");return}let{preferMse:n,streamType:o}=e,a=N(e),c=a===M.M3U8,s=!a||((b=t==null?void 0:t.canPlayType(a))!=null?b:!0),i=f.default.isSupported(),l=((E=(v=window==null?void 0:window.navigator)==null?void 0:v.userAgent)!=null?E:"").toLowerCase().indexOf("android")!==-1&&o===A.LL_LIVE,y=!c||s&&!((n||l)&&i),{src:T}=e;if(t&&s&&y)typeof T=="string"?(t.setAttribute("src",T),e.startTime&&(((k=L.get(t))!=null?k:{}).startTime=e.startTime,t.addEventListener("durationchange",ee,{once:!0}))):t.removeAttribute("src"),t.addEventListener("error",te),t.addEventListener("error",V);else if(r&&T){switch(r.on(f.default.Events.ERROR,(_,m)=>{let re={[f.default.ErrorTypes.NETWORK_ERROR]:u.MEDIA_ERR_NETWORK,[f.default.ErrorTypes.MEDIA_ERROR]:u.MEDIA_ERR_DECODE},I=new u("",re[m.type]);I.fatal=m.fatal,I.data=m,t.dispatchEvent(new CustomEvent("error",{detail:I}))}),t.addEventListener("error",V),q(t,r),t.preload){case"none":t.addEventListener("play",()=>r.loadSource(T),{once:!0});break;case"metadata":let _=r.config.maxBufferLength,m=r.config.maxBufferSize;r.config.maxBufferLength=1,r.config.maxBufferSize=1,t.addEventListener("play",()=>{r.config.maxBufferLength=_,r.config.maxBufferSize=m},{once:!0}),r.loadSource(T);break;default:r.loadSource(T)}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.")};function ee(e){var n;let t=e.target,r=(n=L.get(t))==null?void 0:n.startTime;if(!!r&&$(t.seekable,t.duration,r)){let o=t.preload==="auto";o&&(t.preload="none"),t.currentTime=r,o&&(t.preload="auto")}}async function te(e){if(!e.isTrusted)return;e.stopImmediatePropagation();let t=e.target;if(!(t!=null&&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 V(e){var n,o;if(!(e instanceof CustomEvent)||!(e.detail instanceof u))return;let t=e.target,r=e.detail;!r||!r.fatal||(((n=L.get(t))!=null?n:{}).error=r,(o=t.mux)==null||o.emit("error",{player_error_code:r.code,player_error_message:r.message}))}var Me=(e,t,r)=>{G(t,r),L.set(t,{});let n=J(e,t);return Z(e,t,n),j(e,t,n),n}; | ||
"use strict";var ne=Object.create;var _=Object.defineProperty;var oe=Object.getOwnPropertyDescriptor;var ae=Object.getOwnPropertyNames;var se=Object.getPrototypeOf,ie=Object.prototype.hasOwnProperty;var ce=(e,t)=>{for(var r in t)_(e,r,{get:t[r],enumerable:!0})},U=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of ae(t))!ie.call(e,o)&&o!==r&&_(e,o,{get:()=>t[o],enumerable:!(n=oe(t,o))||n.enumerable});return e};var P=(e,t,r)=>(r=e!=null?ne(se(e)):{},U(t||!e||!e.__esModule?_(r,"default",{value:e,enumerable:!0}):r,e)),ue=e=>U(_({},"__esModule",{value:!0}),e);var me={};ce(me,{ExtensionMimeTypeMap:()=>M,Hls:()=>f.default,MediaError:()=>u,MimeTypeShorthandMap:()=>D,StreamTypes:()=>R,addTextTrack:()=>O,allMediaTypes:()=>ye,generatePlayerInitTime:()=>de,getError:()=>Te,getStreamTypeConfig:()=>X,getType:()=>N,inferMimeTypeFromURL:()=>W,initialize:()=>Me,isMuxVideoSrc:()=>Q,loadMedia:()=>j,mux:()=>S.default,removeTextTrack:()=>Y,setupAutoplay:()=>B,setupHls:()=>J,setupMux:()=>Z,shorthandKeys:()=>le,teardown:()=>G,toMuxVideoURL:()=>fe,toPlaybackIdParts:()=>z});module.exports=ue(me);var S=P(require("mux-embed")),f=P(require("hls.js"));var H=P(require("hls.js")),w={ANY:"any",MUTED:"muted"},pe=Object.values(w),K=e=>typeof e=="boolean"||typeof e=="string"&&pe.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(),h(e,a)},{once:!0}),e.addEventListener("loadedmetadata",()=>{r||(o=!Number.isFinite(e.duration)),h(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&&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,h(e,a))}},h=(e,t)=>{if(!t)return;let r=e.muted,n=()=>e.muted=r;switch(t){case w.ANY:e.play().catch(o=>{e.muted=!0,e.play().catch(n)});break;case w.MUTED:e.muted=!0,e.play().catch(n);break;default:e.play().catch(()=>{});break}};var x=class extends Error{constructor(r,n=x.MEDIA_ERR_CUSTOM,o){var a;super(r);this.name="MediaError",this.code=n,this.fatal=o!=null?o:n>=x.MEDIA_ERR_NETWORK&&n<=x.MEDIA_ERR_ENCRYPTED,this.message||(this.message=(a=x.defaultMessages[this.code])!=null?a:"")}},u=x;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 g=P(require("hls.js"));function q(e,t){t.on(g.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:l,type:y})=>d==(s==null?void 0:s.lang)&&l===c.label&&y.toLowerCase()===c.kind);O(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(g.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 l;(l=i.cues)!=null&&l.getCueById(d.id)||i.addCue(d)}),p&&(i.mode="disabled")}),t.on(g.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&&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(g.default.Events.MANIFEST_LOADED,n),t.once(g.default.Events.MEDIA_ATTACHED,n)}function O(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;function $(e,t,r){t&&r>t&&(r=t);for(let n=0;n<e.length;n++)if(e.start(n)<=r&&e.end(n)>=r)return!0;return!1}var F="mux.com",de=()=>S.default.utils.now(),R={VOD:"on-demand",ON_DEMAND:"on-demand",LIVE:"live",LL_LIVE:"ll-live",DVR:"live:dvr",LL_DVR:"ll-live:dvr"},M={M3U8:"application/vnd.apple.mpegurl",MP4:"video/mp4"},D={HLS:M.M3U8},le=Object.keys(D),ye=[...Object.values(M),"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]},fe=(e,{domain:t=F}={})=>{if(!e)return;let[r,n=""]=z(e);return`https://stream.${t}/${r}.m3u8${n}`},W=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,M)?M[o]:""},N=e=>{let t=e.type;if(t){let n=t.toUpperCase();return C(n,D)?D[n]:t}let{src:r}=e;return r?W(r):""},X=e=>{if([R.LIVE,R.LL_LIVE].includes(e)){let t={backBufferLength:12};return e===R.LL_LIVE?{...t,maxFragLookUpTolerance:.001}:t}return{}},L=new WeakMap,Te=e=>{var t;return(t=L.get(e))==null?void 0:t.error},G=(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",te),e.removeEventListener("error",V),e.removeEventListener("durationchange",ee),L.delete(e))},J=(e,t)=>{var b,v,E;let{debug:r,preferMse:n,streamType:o,startTime:a=-1}=e,c=N(e),s=c===M.M3U8,i=!c||((b=t==null?void 0:t.canPlayType(c))!=null?b:!0),p=f.default.isSupported(),y=((E=(v=window==null?void 0:window.navigator)==null?void 0:v.userAgent)!=null?E:"").toLowerCase().indexOf("android")!==-1;if(s&&!(!s||i&&!((n||y)&&p))&&p){let A={backBufferLength:30,renderTextTracksNatively:!1,liveDurationInfinity:!0},k=X(o);return new f.default({debug:r,startPosition:a,...A,...k})}},Q=({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(F)||!!r&&n.includes(r.toLocaleLowerCase())},Z=(e,t,r)=>{let{envKey:n}=e,o=Q(e);if((n||o)&&t){let{playerInitTime:a,playerSoftwareName:c,playerSoftwareVersion:s,beaconCollectionDomain:i,metadata:p,debug:d}=e,l=y=>typeof y.player_error_code=="string"?!1:typeof e.errorTranslator=="function"?e.errorTranslator(y):y;S.default.monitor(t,{debug:d,beaconCollectionDomain:i,hlsjs:r,Hls:r?f.default:void 0,automaticErrorTracking:!1,errorTranslator:l,data:{...n?{env_key:n}:{},player_software_name:c,player_software_version:s,player_init_time:a,...p}})}},j=(e,t,r)=>{var b,v,E,A;if(!t){console.warn("attempting to load media before mediaEl exists");return}let{preferMse:n,streamType:o}=e,a=N(e),c=a===M.M3U8,s=!a||((b=t==null?void 0:t.canPlayType(a))!=null?b:!0),i=f.default.isSupported(),l=((E=(v=window==null?void 0:window.navigator)==null?void 0:v.userAgent)!=null?E:"").toLowerCase().indexOf("android")!==-1,y=!c||s&&!((n||l)&&i),{src:T}=e;if(t&&s&&y)typeof T=="string"?(t.setAttribute("src",T),e.startTime&&(((A=L.get(t))!=null?A:{}).startTime=e.startTime,t.addEventListener("durationchange",ee,{once:!0}))):t.removeAttribute("src"),t.addEventListener("error",te),t.addEventListener("error",V);else if(r&&T){switch(r.on(f.default.Events.ERROR,(k,m)=>{let re={[f.default.ErrorTypes.NETWORK_ERROR]:u.MEDIA_ERR_NETWORK,[f.default.ErrorTypes.MEDIA_ERROR]:u.MEDIA_ERR_DECODE},I=new u("",re[m.type]);I.fatal=m.fatal,I.data=m,t.dispatchEvent(new CustomEvent("error",{detail:I}))}),t.addEventListener("error",V),q(t,r),t.preload){case"none":t.addEventListener("play",()=>r.loadSource(T),{once:!0});break;case"metadata":let k=r.config.maxBufferLength,m=r.config.maxBufferSize;r.config.maxBufferLength=1,r.config.maxBufferSize=1,t.addEventListener("play",()=>{r.config.maxBufferLength=k,r.config.maxBufferSize=m},{once:!0}),r.loadSource(T);break;default:r.loadSource(T)}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.")};function ee(e){var n;let t=e.target,r=(n=L.get(t))==null?void 0:n.startTime;if(!!r&&$(t.seekable,t.duration,r)){let o=t.preload==="auto";o&&(t.preload="none"),t.currentTime=r,o&&(t.preload="auto")}}async function te(e){if(!e.isTrusted)return;e.stopImmediatePropagation();let t=e.target;if(!(t!=null&&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 V(e){var n,o;if(!(e instanceof CustomEvent)||!(e.detail instanceof u))return;let t=e.target,r=e.detail;!r||!r.fatal||(((n=L.get(t))!=null?n:{}).error=r,(o=t.mux)==null||o.emit("error",{player_error_code:r.code,player_error_message:r.message}))}var Me=(e,t,r)=>{G(t,r),L.set(t,{});let n=J(e,t);return Z(e,t,n),j(e,t,n),n}; | ||
//# sourceMappingURL=index.cjs.js.map |
@@ -38,3 +38,3 @@ { | ||
"src/index.ts": { | ||
"bytes": 17061, | ||
"bytes": 17023, | ||
"imports": [ | ||
@@ -73,3 +73,3 @@ { | ||
"inputs": {}, | ||
"bytes": 1684516 | ||
"bytes": 1684459 | ||
}, | ||
@@ -113,3 +113,3 @@ "dist/playback-core.mjs": { | ||
"src/index.ts": { | ||
"bytesInOutput": 4817 | ||
"bytesInOutput": 4801 | ||
}, | ||
@@ -129,5 +129,5 @@ "src/autoplay.ts": { | ||
}, | ||
"bytes": 472890 | ||
"bytes": 472874 | ||
} | ||
} | ||
} |
{ | ||
"name": "@mux/playback-core", | ||
"version": "0.9.1-canary.38-6c5a124", | ||
"version": "0.9.1-canary.39-ad43416", | ||
"description": "Core library for media playback in the browser shared by mux elements", | ||
@@ -49,3 +49,3 @@ "main": "./dist/index.cjs.js", | ||
"dependencies": { | ||
"@mux/mux-elements-codemod": "1.1.2-canary.39-6c5a124", | ||
"@mux/mux-elements-codemod": "1.1.2-canary.40-ad43416", | ||
"hls.js": "1.1.5", | ||
@@ -52,0 +52,0 @@ "mux-embed": "^4.7.0" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
4461452
+ Added@mux/mux-elements-codemod@1.1.2-canary.40-ad43416(transitive)
- Removed@mux/mux-elements-codemod@1.1.2-canary.39-6c5a124(transitive)