@mux/mux-video 0.15.2 → 0.15.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +36 -24
- package/dist/index.cjs.js.map +4 -4
- package/dist/index.mjs +36 -24
- package/dist/index.mjs.map +4 -4
- package/dist/mux-video.js +65 -53
- package/dist/mux-video.js.map +4 -4
- package/dist/mux-video.mjs +65 -53
- package/dist/mux-video.mjs.map +4 -4
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/index.d.ts +4 -2
- package/dist/types-ts3.4/index.d.ts +4 -2
- package/package.json +6 -5
- package/dist/types/CustomVideoElement.d.ts +0 -14
- package/dist/types-ts3.4/CustomVideoElement.d.ts +0 -11
package/dist/index.mjs
CHANGED
|
@@ -1,27 +1,39 @@
|
|
|
1
|
-
var Qe=Object.defineProperty;var et=(a,s,e)=>s in a?Qe(a,s,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[s]=e;var j=(a,s,e)=>(et(a,typeof s!="symbol"?s+"":s,e),e),ye=(a,s,e)=>{if(!s.has(a))throw TypeError("Cannot "+e)};var i=(a,s,e)=>(ye(a,s,"read from private field"),e?e.call(a):s.get(a)),u=(a,s,e)=>{if(s.has(a))throw TypeError("Cannot add the same private member more than once");s instanceof WeakSet?s.add(a):s.set(a,e)},l=(a,s,e,o)=>(ye(a,s,"write to private field"),o?o.call(a,e):s.set(a,e),e);var h=(a,s,e)=>(ye(a,s,"access private method"),e);var F=class{addEventListener(){}removeEventListener(){}dispatchEvent(s){return!0}};if(typeof DocumentFragment=="undefined"){class a extends F{}globalThis.DocumentFragment=a}var q=class extends F{},ge=class extends F{},tt={get(a){},define(a,s,e){},upgrade(a){},whenDefined(a){return Promise.resolve(q)}},$,be=class{constructor(s,e={}){u(this,$,void 0);l(this,$,e==null?void 0:e.detail)}get detail(){return i(this,$)}initCustomEvent(){}};$=new WeakMap;function st(a,s){return new q}var Ge={document:{createElement:st},DocumentFragment,customElements:tt,CustomEvent:be,EventTarget:F,HTMLElement:q,HTMLVideoElement:ge},Ue=typeof window=="undefined"||typeof globalThis.customElements=="undefined",S=Ue?Ge:globalThis,Te=Ue?Ge.document:globalThis.document;import{initialize as ot,teardown as ct,generatePlayerInitTime as ut,PlaybackTypes as Ee,toMuxVideoURL as lt,MediaError as Yt,getError as dt,CmcdTypeValues as Ze,addCuePoints as ht,getCuePoints as mt,getActiveCuePoint as Et,getStartDate as ft,getCurrentPdt as pt,getStreamType as yt,getTargetLiveWindow as gt,getLiveEdgeStart as bt,getSeekable as Tt}from"@mux/playback-core";var it=()=>{try{return"0.15.2"}catch{}return"UNKNOWN"},rt=it(),Ye=()=>rt;var Be=a=>{var s,e,o,c,m,We,f,le,A,C,N,de,x,he,re,Ve,ae,Ke,B,Ae,W,b,I,L,k,_,R,X,ne,He,V,ve,oe,je,K,Pe,ce,qe,H,Se;return s=class extends a{constructor(){super();u(this,R);u(this,ne);u(this,V);u(this,oe);u(this,K);u(this,ce);u(this,H);j(this,"castEnabled",!1);u(this,W,{paused:!1});u(this,b,void 0);u(this,I,{});u(this,L,void 0);u(this,k,void 0);u(this,_,void 0);s.instances.add(this),h(this,K,Pe).call(this)}static get castElement(){return i(s,e)}static get castEnabled(){return i(s,o)}static get castState(){var t;return(t=i(s,A,C))==null?void 0:t.getCastState()}static async exitCast(){try{await i(s,A,C).endCurrentSession(!0)}catch(r){console.error(r);return}}get castPlayer(){if(s.castElement===this)return i(this,b)}attributeChangedCallback(t){if(!!this.castPlayer)switch(t){case"cast-stream-type":case"cast-src":this.load();break}}async requestCast(t={}){var r;h(r=s,B,Ae).call(r,t),l(s,e,this),Object.entries(i(this,I)).forEach(([d,p])=>{i(this,b).controller.addEventListener(d,p)});try{await i(s,A,C).requestSession()}catch{l(s,e,void 0);return}i(this,W).paused=super.paused,super.pause(),this.muted=super.muted;try{await this.load()}catch(d){console.error(d)}}async load(){var P,D;if(!this.castPlayer)return super.load();let t=new chrome.cast.media.MediaInfo(this.castSrc,this.castContentType),r=[...this.querySelectorAll("track")].filter(({kind:v,src:T})=>T&&(v==="subtitles"||v==="captions")),d=[],p=0;r.length&&(t.tracks=r.map(v=>{let T=++p;d.length===0&&v.track.mode==="showing"&&d.push(T);let w=new chrome.cast.media.Track(T,chrome.cast.media.TrackType.TEXT);return w.trackContentId=v.src,w.trackContentType="text/vtt",w.subtype=v.kind==="captions"?chrome.cast.media.TextTrackType.CAPTIONS:chrome.cast.media.TextTrackType.SUBTITLES,w.name=v.label,w.language=v.srclang,w})),this.castStreamType==="live"?t.streamType=chrome.cast.media.StreamType.LIVE:t.streamType=chrome.cast.media.StreamType.BUFFERED,t.metadata=new chrome.cast.media.GenericMediaMetadata,t.metadata.title=this.title,t.metadata.images=[{url:this.poster}];let y=new chrome.cast.media.LoadRequest(t);y.currentTime=(P=super.currentTime)!=null?P:0,y.autoplay=!i(this,W).paused,y.activeTrackIds=d,await((D=i(s,N,de))==null?void 0:D.loadMedia(y)),this.dispatchEvent(new Event("volumechange"))}play(){var t;if(this.castPlayer){this.castPlayer.isPaused&&((t=this.castPlayer.controller)==null||t.playOrPause());return}return super.play()}pause(){var t;if(this.castPlayer){this.castPlayer.isPaused||(t=this.castPlayer.controller)==null||t.playOrPause();return}super.pause()}get castSrc(){var t,r,d;return(d=(r=this.getAttribute("cast-src"))!=null?r:(t=this.querySelector("source"))==null?void 0:t.src)!=null?d:this.currentSrc}set castSrc(t){this.castSrc!=t&&this.setAttribute("cast-src",`${t}`)}get castContentType(){var t;return(t=this.getAttribute("cast-content-type"))!=null?t:void 0}set castContentType(t){this.setAttribute("cast-content-type",`${t}`)}get castStreamType(){var t,r;return(r=(t=this.getAttribute("cast-stream-type"))!=null?t:this.streamType)!=null?r:void 0}set castStreamType(t){this.setAttribute("cast-stream-type",`${t}`)}get readyState(){if(this.castPlayer)switch(this.castPlayer.playerState){case chrome.cast.media.PlayerState.IDLE:return 0;case chrome.cast.media.PlayerState.BUFFERING:return 2;default:return 3}return super.readyState}get paused(){return this.castPlayer?this.castPlayer.isPaused:super.paused}get muted(){var t;return this.castPlayer?(t=this.castPlayer)==null?void 0:t.isMuted:super.muted}set muted(t){var r;if(this.castPlayer){(t&&!this.castPlayer.isMuted||!t&&this.castPlayer.isMuted)&&((r=this.castPlayer.controller)==null||r.muteOrUnmute());return}super.muted=t}get volume(){var t,r;return this.castPlayer?(r=(t=this.castPlayer)==null?void 0:t.volumeLevel)!=null?r:1:super.volume}set volume(t){var r;if(this.castPlayer){this.castPlayer.volumeLevel=t,(r=this.castPlayer.controller)==null||r.setVolumeLevel();return}super.volume=t}get duration(){var t,r;return this.castPlayer&&i(this,R,X)?(r=(t=this.castPlayer)==null?void 0:t.duration)!=null?r:NaN:super.duration}get currentTime(){var t,r;return this.castPlayer&&i(this,R,X)?(r=(t=this.castPlayer)==null?void 0:t.currentTime)!=null?r:0:super.currentTime}set currentTime(t){var r;if(this.castPlayer){this.castPlayer.currentTime=t,(r=this.castPlayer.controller)==null||r.seek();return}super.currentTime=t}get onentercast(){return i(this,L)}set onentercast(t){i(this,L)&&(this.removeEventListener("entercast",i(this,L)),l(this,L,null)),typeof t=="function"&&(l(this,L,t),this.addEventListener("entercast",t))}get onleavecast(){return i(this,k)}set onleavecast(t){i(this,k)&&(this.removeEventListener("leavecast",i(this,k)),l(this,k,null)),typeof t=="function"&&(l(this,k,t),this.addEventListener("leavecast",t))}get oncastchange(){return i(this,_)}set oncastchange(t){i(this,_)&&(this.removeEventListener("castchange",i(this,_)),l(this,_,null)),typeof t=="function"&&(l(this,_,t),this.addEventListener("castchange",t))}},e=new WeakMap,o=new WeakMap,c=new WeakMap,m=new WeakSet,We=function(){return typeof chrome!="undefined"&&chrome.cast&&chrome.cast.isAvailable},f=new WeakSet,le=function(){return typeof cast!="undefined"&&cast.framework},A=new WeakSet,C=function(){if(i(s,f,le))return cast.framework.CastContext.getInstance()},N=new WeakSet,de=function(){var t;return(t=i(s,A,C))==null?void 0:t.getCurrentSession()},x=new WeakSet,he=function(){var t;return(t=i(s,N,de))==null?void 0:t.getSessionObj().media[0]},re=new WeakSet,Ve=function(t){return new Promise((r,d)=>{i(s,x,he).editTracksInfo(t,r,d)})},ae=new WeakSet,Ke=function(t){return new Promise((r,d)=>{i(s,x,he).getStatus(t,r,d)})},B=new WeakSet,Ae=function(t){return i(s,A,C).setOptions({receiverApplicationId:chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID,autoJoinPolicy:chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED,androidReceiverCompatible:!1,language:"en-US",resumeSavedSession:!0,...t})},W=new WeakMap,b=new WeakMap,I=new WeakMap,L=new WeakMap,k=new WeakMap,_=new WeakMap,R=new WeakSet,X=function(){var t;return(t=this.castPlayer)==null?void 0:t.isMediaLoaded},ne=new WeakSet,He=function(){i(s,e)===this&&(Object.entries(i(this,I)).forEach(([t,r])=>{i(this,b).controller.removeEventListener(t,r)}),l(s,e,void 0),this.muted=i(this,b).isMuted,this.currentTime=i(this,b).savedPlayerState.currentTime,i(this,b).savedPlayerState.isPaused===!1&&this.play())},V=new WeakSet,ve=function(){this.dispatchEvent(new CustomEvent("castchange",{detail:i(s,A,C).getCastState()}))},oe=new WeakSet,je=async function(){var r,d;let{SESSION_RESUMED:t}=cast.framework.SessionState;if(i(s,A,C).getSessionState()===t&&this.castSrc===((r=i(s,x,he))==null?void 0:r.media.contentId)){l(s,e,this),Object.entries(i(this,I)).forEach(([p,y])=>{i(this,b).controller.addEventListener(p,y)});try{await h(d=s,ae,Ke).call(d,new chrome.cast.media.GetStatusRequest)}catch(p){console.error(p)}i(this,I)[cast.framework.RemotePlayerEventType.IS_PAUSED_CHANGED](),i(this,I)[cast.framework.RemotePlayerEventType.PLAYER_STATE_CHANGED]()}},K=new WeakSet,Pe=function(){var t;!i(s,f,le)||this.castEnabled||(this.castEnabled=!0,h(t=s,B,Ae).call(t),this.textTracks.addEventListener("change",h(this,H,Se).bind(this)),h(this,V,ve).call(this),l(this,b,new cast.framework.RemotePlayer),new cast.framework.RemotePlayerController(i(this,b)),l(this,I,{[cast.framework.RemotePlayerEventType.IS_CONNECTED_CHANGED]:({value:r})=>{r===!1&&h(this,ne,He).call(this),this.dispatchEvent(new Event(r?"entercast":"leavecast"))},[cast.framework.RemotePlayerEventType.DURATION_CHANGED]:()=>{this.dispatchEvent(new Event("durationchange"))},[cast.framework.RemotePlayerEventType.VOLUME_LEVEL_CHANGED]:()=>{this.dispatchEvent(new Event("volumechange"))},[cast.framework.RemotePlayerEventType.IS_MUTED_CHANGED]:()=>{this.dispatchEvent(new Event("volumechange"))},[cast.framework.RemotePlayerEventType.CURRENT_TIME_CHANGED]:()=>{!i(this,R,X)||this.dispatchEvent(new Event("timeupdate"))},[cast.framework.RemotePlayerEventType.VIDEO_INFO_CHANGED]:()=>{this.dispatchEvent(new Event("resize"))},[cast.framework.RemotePlayerEventType.IS_PAUSED_CHANGED]:()=>{this.dispatchEvent(new Event(this.paused?"pause":"play"))},[cast.framework.RemotePlayerEventType.PLAYER_STATE_CHANGED]:()=>{var r,d;((r=this.castPlayer)==null?void 0:r.playerState)!==chrome.cast.media.PlayerState.PAUSED&&this.dispatchEvent(new Event({[chrome.cast.media.PlayerState.PLAYING]:"playing",[chrome.cast.media.PlayerState.BUFFERING]:"waiting",[chrome.cast.media.PlayerState.IDLE]:"emptied"}[(d=this.castPlayer)==null?void 0:d.playerState]))},[cast.framework.RemotePlayerEventType.IS_MEDIA_LOADED_CHANGED]:async()=>{!i(this,R,X)||(await Promise.resolve(),h(this,ce,qe).call(this))}}))},ce=new WeakSet,qe=function(){h(this,H,Se).call(this)},H=new WeakSet,Se=async function(){var ke,_e,Me,Re,De,we;if(!this.castPlayer)return;let r=((_e=(ke=i(this,b).mediaInfo)==null?void 0:ke.tracks)!=null?_e:[]).filter(({type:E})=>E===chrome.cast.media.TrackType.TEXT),d=[...this.textTracks].filter(({kind:E})=>E==="subtitles"||E==="captions"),p=r.map(({language:E,name:ue,trackId:pe})=>{var xe;let{mode:Ne}=(xe=d.find(Fe=>Fe.language===E&&Fe.label===ue))!=null?xe:{};return Ne?{mode:Ne,trackId:pe}:!1}).filter(Boolean),P=p.filter(({mode:E})=>E!=="showing").map(({trackId:E})=>E),D=p.find(({mode:E})=>E==="showing"),v=(De=(Re=(Me=i(s,N,de))==null?void 0:Me.getSessionObj().media[0])==null?void 0:Re.activeTrackIds)!=null?De:[],T=v;if(v.length&&(T=T.filter(E=>!P.includes(E))),D!=null&&D.trackId&&(T=[...T,D.trackId]),T=[...new Set(T)],!((E,ue)=>E.length===ue.length&&E.every(pe=>ue.includes(pe)))(v,T))try{let E=new chrome.cast.media.EditTracksInfoRequest(T);await h(we=s,re,Ve).call(we,E)}catch(E){console.error(E)}},u(s,m),u(s,f),u(s,A),u(s,N),u(s,x),u(s,re),u(s,ae),u(s,B),j(s,"observedAttributes",["cast-src","cast-content-type","cast-stream-type"]),j(s,"instances",new Set),u(s,e,void 0),u(s,o,!1),j(s,"initCast",()=>{var t;i(s,m,We)?i(s,f,le)?i(t=s,c).call(t,chrome.cast.isAvailable):customElements.whenDefined("google-cast-button").then(()=>{var r;return i(r=s,c).call(r,chrome.cast.isAvailable)}):globalThis.__onGCastApiAvailable=()=>{customElements.whenDefined("google-cast-button").then(()=>{var r;return i(r=s,c).call(r,chrome.cast.isAvailable)})}}),u(s,c,t=>{if(t){l(s,o,!0);let{CAST_STATE_CHANGED:r}=cast.framework.CastContextEventType;i(s,A,C).addEventListener(r,p=>{s.instances.forEach(y=>{var P;return h(P=y,V,ve).call(P,p)})});let{SESSION_STATE_CHANGED:d}=cast.framework.CastContextEventType;i(s,A,C).addEventListener(d,p=>{s.instances.forEach(y=>{var P;return h(P=y,oe,je).call(P,p)})}),s.instances.forEach(p=>{var y;return h(y=p,K,Pe).call(y)})}}),s},Ce=globalThis.HTMLVideoElement?Be(HTMLVideoElement):Be(Object);globalThis.customElements&&!globalThis.customElements.get("castable-video")&&(customElements.define("castable-video",Ce,{extends:"video"}),globalThis.CastableVideoElement=Ce);Ce.initCast();var $e=["abort","canplay","canplaythrough","durationchange","emptied","encrypted","ended","error","loadeddata","loadedmetadata","loadstart","pause","play","playing","progress","ratechange","seeked","seeking","stalled","suspend","timeupdate","volumechange","waiting","waitingforkey","resize","enterpictureinpicture","leavepictureinpicture","castchange","entercast","leavecast"],Xe=Te.createElement("template");Xe.innerHTML=`
|
|
2
|
-
<style>
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
height: auto;
|
|
8
|
-
}
|
|
1
|
+
var re=Object.defineProperty;var ae=(o,s,t)=>s in o?re(o,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[s]=t;var x=(o,s,t)=>(ae(o,typeof s!="symbol"?s+"":s,t),t),At=(o,s,t)=>{if(!s.has(o))throw TypeError("Cannot "+t)};var i=(o,s,t)=>(At(o,s,"read from private field"),t?t.call(o):s.get(o)),n=(o,s,t)=>{if(s.has(o))throw TypeError("Cannot add the same private member more than once");s instanceof WeakSet?s.add(o):s.set(o,t)},E=(o,s,t,u)=>(At(o,s,"write to private field"),u?u.call(o,t):s.set(o,t),t);var f=(o,s,t)=>(At(o,s,"access private method"),t);var W=class{addEventListener(){}removeEventListener(){}dispatchEvent(s){return!0}};if(typeof DocumentFragment=="undefined"){class o extends W{}globalThis.DocumentFragment=o}var z=class extends W{},Tt=class extends W{},ne={get(o){},define(o,s,t){},upgrade(o){},whenDefined(o){return Promise.resolve(z)}},J,vt=class{constructor(s,t={}){n(this,J,void 0);E(this,J,t==null?void 0:t.detail)}get detail(){return i(this,J)}initCustomEvent(){}};J=new WeakMap;function oe(o,s){return new z}var Wt={document:{createElement:oe},DocumentFragment,customElements:ne,CustomEvent:vt,EventTarget:W,HTMLElement:z,HTMLVideoElement:Tt},Vt=typeof window=="undefined"||typeof globalThis.customElements=="undefined",Q=Vt?Wt:globalThis,Le=Vt?Wt.document:globalThis.document;import{initialize as de,teardown as he,generatePlayerInitTime as me,PlaybackTypes as gt,toMuxVideoURL as Ee,MediaError as $e,getError as fe,CmcdTypeValues as ie,addCuePoints as pe,getCuePoints as ye,getActiveCuePoint as ge,getStartDate as be,getCurrentPdt as Ae,getStreamType as Te,getTargetLiveWindow as ve,getLiveEdgeStart as Se,getSeekable as Pe}from"@mux/playback-core";var ce=()=>{try{return"0.15.3"}catch{}return"UNKNOWN"},ue=ce(),Kt=()=>ue;var Ht=o=>{var s,t,u,l,M,jt,S,Et,T,D,L,ft,U,pt,ot,qt,ut,$t,Y,St,c,p,g,h,m,A,I,Z,lt,Xt,q,Pt,dt,zt,$,Ct,ht,Jt,X,Ot;return s=class extends o{constructor(){super();n(this,I);n(this,lt);n(this,q);n(this,dt);n(this,$);n(this,ht);n(this,X);x(this,"castEnabled",!1);n(this,c,{paused:!1});n(this,p,void 0);n(this,g,{});n(this,h,void 0);n(this,m,void 0);n(this,A,void 0);s.instances.add(this),f(this,$,Ct).call(this)}static get castElement(){return i(s,t)}static get castEnabled(){return i(s,u)}static get castState(){var e;return(e=i(s,T,D))==null?void 0:e.getCastState()}static async exitCast(){try{await i(s,T,D).endCurrentSession(!0)}catch(r){console.error(r);return}}get castPlayer(){if(s.castElement===this)return i(this,p)}attributeChangedCallback(e){if(!!this.castPlayer)switch(e){case"cast-stream-type":case"cast-src":this.load();break}}async requestCast(e={}){var r;f(r=s,Y,St).call(r,e),E(s,t,this),Object.entries(i(this,g)).forEach(([y,v])=>{i(this,p).controller.addEventListener(y,v)});try{await i(s,T,D).requestSession()}catch{E(s,t,void 0);return}i(this,c).paused=super.paused,super.pause(),this.muted=super.muted;try{await this.load()}catch(y){console.error(y)}}async load(){var _,G;if(!this.castPlayer)return super.load();let e=new chrome.cast.media.MediaInfo(this.castSrc,this.castContentType),r=[...this.querySelectorAll("track")].filter(({kind:R,src:k})=>k&&(R==="subtitles"||R==="captions")),y=[],v=0;r.length&&(e.tracks=r.map(R=>{let k=++v;y.length===0&&R.track.mode==="showing"&&y.push(k);let F=new chrome.cast.media.Track(k,chrome.cast.media.TrackType.TEXT);return F.trackContentId=R.src,F.trackContentType="text/vtt",F.subtype=R.kind==="captions"?chrome.cast.media.TextTrackType.CAPTIONS:chrome.cast.media.TextTrackType.SUBTITLES,F.name=R.label,F.language=R.srclang,F})),this.castStreamType==="live"?e.streamType=chrome.cast.media.StreamType.LIVE:e.streamType=chrome.cast.media.StreamType.BUFFERED,e.metadata=new chrome.cast.media.GenericMediaMetadata,e.metadata.title=this.title,e.metadata.images=[{url:this.poster}];let O=new chrome.cast.media.LoadRequest(e);O.currentTime=(_=super.currentTime)!=null?_:0,O.autoplay=!i(this,c).paused,O.activeTrackIds=y,await((G=i(s,L,ft))==null?void 0:G.loadMedia(O)),this.dispatchEvent(new Event("volumechange"))}play(){var e;if(this.castPlayer){this.castPlayer.isPaused&&((e=this.castPlayer.controller)==null||e.playOrPause());return}return super.play()}pause(){var e;if(this.castPlayer){this.castPlayer.isPaused||(e=this.castPlayer.controller)==null||e.playOrPause();return}super.pause()}get castSrc(){var e,r,y;return(y=(r=this.getAttribute("cast-src"))!=null?r:(e=this.querySelector("source"))==null?void 0:e.src)!=null?y:this.currentSrc}set castSrc(e){this.castSrc!=e&&this.setAttribute("cast-src",`${e}`)}get castContentType(){var e;return(e=this.getAttribute("cast-content-type"))!=null?e:void 0}set castContentType(e){this.setAttribute("cast-content-type",`${e}`)}get castStreamType(){var e,r;return(r=(e=this.getAttribute("cast-stream-type"))!=null?e:this.streamType)!=null?r:void 0}set castStreamType(e){this.setAttribute("cast-stream-type",`${e}`)}get readyState(){if(this.castPlayer)switch(this.castPlayer.playerState){case chrome.cast.media.PlayerState.IDLE:return 0;case chrome.cast.media.PlayerState.BUFFERING:return 2;default:return 3}return super.readyState}get paused(){return this.castPlayer?this.castPlayer.isPaused:super.paused}get muted(){var e;return this.castPlayer?(e=this.castPlayer)==null?void 0:e.isMuted:super.muted}set muted(e){var r;if(this.castPlayer){(e&&!this.castPlayer.isMuted||!e&&this.castPlayer.isMuted)&&((r=this.castPlayer.controller)==null||r.muteOrUnmute());return}super.muted=e}get volume(){var e,r;return this.castPlayer?(r=(e=this.castPlayer)==null?void 0:e.volumeLevel)!=null?r:1:super.volume}set volume(e){var r;if(this.castPlayer){this.castPlayer.volumeLevel=e,(r=this.castPlayer.controller)==null||r.setVolumeLevel();return}super.volume=e}get duration(){var e,r;return this.castPlayer&&i(this,I,Z)?(r=(e=this.castPlayer)==null?void 0:e.duration)!=null?r:NaN:super.duration}get currentTime(){var e,r;return this.castPlayer&&i(this,I,Z)?(r=(e=this.castPlayer)==null?void 0:e.currentTime)!=null?r:0:super.currentTime}set currentTime(e){var r;if(this.castPlayer){this.castPlayer.currentTime=e,(r=this.castPlayer.controller)==null||r.seek();return}super.currentTime=e}get onentercast(){return i(this,h)}set onentercast(e){i(this,h)&&(this.removeEventListener("entercast",i(this,h)),E(this,h,null)),typeof e=="function"&&(E(this,h,e),this.addEventListener("entercast",e))}get onleavecast(){return i(this,m)}set onleavecast(e){i(this,m)&&(this.removeEventListener("leavecast",i(this,m)),E(this,m,null)),typeof e=="function"&&(E(this,m,e),this.addEventListener("leavecast",e))}get oncastchange(){return i(this,A)}set oncastchange(e){i(this,A)&&(this.removeEventListener("castchange",i(this,A)),E(this,A,null)),typeof e=="function"&&(E(this,A,e),this.addEventListener("castchange",e))}},t=new WeakMap,u=new WeakMap,l=new WeakMap,M=new WeakSet,jt=function(){return typeof chrome!="undefined"&&chrome.cast&&chrome.cast.isAvailable},S=new WeakSet,Et=function(){return typeof cast!="undefined"&&cast.framework},T=new WeakSet,D=function(){if(i(s,S,Et))return cast.framework.CastContext.getInstance()},L=new WeakSet,ft=function(){var e;return(e=i(s,T,D))==null?void 0:e.getCurrentSession()},U=new WeakSet,pt=function(){var e;return(e=i(s,L,ft))==null?void 0:e.getSessionObj().media[0]},ot=new WeakSet,qt=function(e){return new Promise((r,y)=>{i(s,U,pt).editTracksInfo(e,r,y)})},ut=new WeakSet,$t=function(e){return new Promise((r,y)=>{i(s,U,pt).getStatus(e,r,y)})},Y=new WeakSet,St=function(e){return i(s,T,D).setOptions({receiverApplicationId:chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID,autoJoinPolicy:chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED,androidReceiverCompatible:!1,language:"en-US",resumeSavedSession:!0,...e})},c=new WeakMap,p=new WeakMap,g=new WeakMap,h=new WeakMap,m=new WeakMap,A=new WeakMap,I=new WeakSet,Z=function(){var e;return(e=this.castPlayer)==null?void 0:e.isMediaLoaded},lt=new WeakSet,Xt=function(){i(s,t)===this&&(Object.entries(i(this,g)).forEach(([e,r])=>{i(this,p).controller.removeEventListener(e,r)}),E(s,t,void 0),this.muted=i(this,p).isMuted,this.currentTime=i(this,p).savedPlayerState.currentTime,i(this,p).savedPlayerState.isPaused===!1&&this.play())},q=new WeakSet,Pt=function(){this.dispatchEvent(new CustomEvent("castchange",{detail:i(s,T,D).getCastState()}))},dt=new WeakSet,zt=async function(){var r,y;let{SESSION_RESUMED:e}=cast.framework.SessionState;if(i(s,T,D).getSessionState()===e&&this.castSrc===((r=i(s,U,pt))==null?void 0:r.media.contentId)){E(s,t,this),Object.entries(i(this,g)).forEach(([v,O])=>{i(this,p).controller.addEventListener(v,O)});try{await f(y=s,ut,$t).call(y,new chrome.cast.media.GetStatusRequest)}catch(v){console.error(v)}i(this,g)[cast.framework.RemotePlayerEventType.IS_PAUSED_CHANGED](),i(this,g)[cast.framework.RemotePlayerEventType.PLAYER_STATE_CHANGED]()}},$=new WeakSet,Ct=function(){var e;!i(s,S,Et)||this.castEnabled||(this.castEnabled=!0,f(e=s,Y,St).call(e),this.textTracks.addEventListener("change",f(this,X,Ot).bind(this)),f(this,q,Pt).call(this),E(this,p,new cast.framework.RemotePlayer),new cast.framework.RemotePlayerController(i(this,p)),E(this,g,{[cast.framework.RemotePlayerEventType.IS_CONNECTED_CHANGED]:({value:r})=>{r===!1&&f(this,lt,Xt).call(this),this.dispatchEvent(new Event(r?"entercast":"leavecast"))},[cast.framework.RemotePlayerEventType.DURATION_CHANGED]:()=>{this.dispatchEvent(new Event("durationchange"))},[cast.framework.RemotePlayerEventType.VOLUME_LEVEL_CHANGED]:()=>{this.dispatchEvent(new Event("volumechange"))},[cast.framework.RemotePlayerEventType.IS_MUTED_CHANGED]:()=>{this.dispatchEvent(new Event("volumechange"))},[cast.framework.RemotePlayerEventType.CURRENT_TIME_CHANGED]:()=>{!i(this,I,Z)||this.dispatchEvent(new Event("timeupdate"))},[cast.framework.RemotePlayerEventType.VIDEO_INFO_CHANGED]:()=>{this.dispatchEvent(new Event("resize"))},[cast.framework.RemotePlayerEventType.IS_PAUSED_CHANGED]:()=>{this.dispatchEvent(new Event(this.paused?"pause":"play"))},[cast.framework.RemotePlayerEventType.PLAYER_STATE_CHANGED]:()=>{var r,y;((r=this.castPlayer)==null?void 0:r.playerState)!==chrome.cast.media.PlayerState.PAUSED&&this.dispatchEvent(new Event({[chrome.cast.media.PlayerState.PLAYING]:"playing",[chrome.cast.media.PlayerState.BUFFERING]:"waiting",[chrome.cast.media.PlayerState.IDLE]:"emptied"}[(y=this.castPlayer)==null?void 0:y.playerState]))},[cast.framework.RemotePlayerEventType.IS_MEDIA_LOADED_CHANGED]:async()=>{!i(this,I,Z)||(await Promise.resolve(),f(this,ht,Jt).call(this))}}))},ht=new WeakSet,Jt=function(){f(this,X,Ot).call(this)},X=new WeakSet,Ot=async function(){var Dt,wt,Nt,xt,Gt,Ft;if(!this.castPlayer)return;let r=((wt=(Dt=i(this,p).mediaInfo)==null?void 0:Dt.tracks)!=null?wt:[]).filter(({type:b})=>b===chrome.cast.media.TrackType.TEXT),y=[...this.textTracks].filter(({kind:b})=>b==="subtitles"||b==="captions"),v=r.map(({language:b,name:mt,trackId:bt})=>{var Yt;let{mode:Ut}=(Yt=y.find(Bt=>Bt.language===b&&Bt.label===mt))!=null?Yt:{};return Ut?{mode:Ut,trackId:bt}:!1}).filter(Boolean),_=v.filter(({mode:b})=>b!=="showing").map(({trackId:b})=>b),G=v.find(({mode:b})=>b==="showing"),R=(Gt=(xt=(Nt=i(s,L,ft))==null?void 0:Nt.getSessionObj().media[0])==null?void 0:xt.activeTrackIds)!=null?Gt:[],k=R;if(R.length&&(k=k.filter(b=>!_.includes(b))),G!=null&&G.trackId&&(k=[...k,G.trackId]),k=[...new Set(k)],!((b,mt)=>b.length===mt.length&&b.every(bt=>mt.includes(bt)))(R,k))try{let b=new chrome.cast.media.EditTracksInfoRequest(k);await f(Ft=s,ot,qt).call(Ft,b)}catch(b){console.error(b)}},n(s,M),n(s,S),n(s,T),n(s,L),n(s,U),n(s,ot),n(s,ut),n(s,Y),x(s,"observedAttributes",["cast-src","cast-content-type","cast-stream-type"]),x(s,"instances",new Set),n(s,t,void 0),n(s,u,!1),x(s,"initCast",()=>{var e;i(s,M,jt)?i(s,S,Et)?i(e=s,l).call(e,chrome.cast.isAvailable):customElements.whenDefined("google-cast-button").then(()=>{var r;return i(r=s,l).call(r,chrome.cast.isAvailable)}):globalThis.__onGCastApiAvailable=()=>{customElements.whenDefined("google-cast-button").then(()=>{var r;return i(r=s,l).call(r,chrome.cast.isAvailable)})}}),n(s,l,e=>{if(e){E(s,u,!0);let{CAST_STATE_CHANGED:r}=cast.framework.CastContextEventType;i(s,T,D).addEventListener(r,v=>{s.instances.forEach(O=>{var _;return f(_=O,q,Pt).call(_,v)})});let{SESSION_STATE_CHANGED:y}=cast.framework.CastContextEventType;i(s,T,D).addEventListener(y,v=>{s.instances.forEach(O=>{var _;return f(_=O,dt,zt).call(_,v)})}),s.instances.forEach(v=>{var O;return f(O=v,$,Ct).call(O)})}}),s},Mt=globalThis.HTMLVideoElement?Ht(HTMLVideoElement):Ht(Object);globalThis.customElements&&!globalThis.customElements.get("castable-video")&&(customElements.define("castable-video",Mt,{extends:"video"}),globalThis.CastableVideoElement=Mt);Mt.initCast();var Lt=["abort","canplay","canplaythrough","durationchange","emptied","encrypted","ended","error","loadeddata","loadedmetadata","loadstart","pause","play","playing","progress","ratechange","seeked","seeking","stalled","suspend","timeupdate","volumechange","waiting","waitingforkey","resize","enterpictureinpicture","leavepictureinpicture","webkitbeginfullscreen","webkitendfullscreen","webkitpresentationmodechanged"],Qt,It=(Qt=globalThis.document)==null?void 0:Qt.createElement("template");It&&(It.innerHTML=`
|
|
2
|
+
<style>
|
|
3
|
+
:host {
|
|
4
|
+
display: inline-block;
|
|
5
|
+
line-height: 0;
|
|
6
|
+
}
|
|
9
7
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
8
|
+
audio {
|
|
9
|
+
max-width: 100%;
|
|
10
|
+
max-height: 100%;
|
|
11
|
+
min-width: 100%;
|
|
12
|
+
min-height: 100%;
|
|
13
|
+
}
|
|
14
|
+
</style>
|
|
15
|
+
<slot></slot>
|
|
16
|
+
`);var Zt,kt=(Zt=globalThis.document)==null?void 0:Zt.createElement("template");kt&&(kt.innerHTML=`
|
|
17
|
+
<style>
|
|
18
|
+
:host {
|
|
19
|
+
display: inline-block;
|
|
20
|
+
line-height: 0;
|
|
21
|
+
}
|
|
18
22
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
`;var z,G,me,J,Oe,M=class extends S.HTMLElement{constructor(){super();u(this,G);u(this,J);u(this,z,void 0);this.attachShadow({mode:"open"}),this.isConnected&&h(this,G,me).call(this)}static get observedAttributes(){let e=[],o=m=>m.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase();Object.getOwnPropertyNames(this.prototype).forEach(m=>{let g=!1;try{typeof this.prototype[m]=="function"&&(g=!0)}catch{}!g&&m!==m.toUpperCase()&&e.push(m.toLowerCase(),o(m))});let c=Object.getPrototypeOf(this).observedAttributes;return c&&(e=e.concat(c)),e}attributeChangedCallback(e,o,c){h(this,G,me).call(this),h(this,J,Oe).call(this,e,o,c)}connectedCallback(){h(this,G,me).call(this)}};z=new WeakMap,G=new WeakSet,me=function(){if(i(this,z))return;l(this,z,!0),this.shadowRoot.append(Xe.content.cloneNode(!0)),this.nativeEl=this.shadowRoot.querySelector("video"),$e.forEach(o=>{this.nativeEl.addEventListener(o,c=>{this.dispatchEvent(new CustomEvent(c.type,{detail:c.detail}))})});let e=this.shadowRoot.querySelector("slot");e.addEventListener("slotchange",()=>{e.assignedElements().forEach(o=>{!["track","source"].includes(o.localName)||this.nativeEl.append(o)})}),Array.prototype.forEach.call(this.attributes,o=>{h(this,J,Oe).call(this,o.name,null,o.value)}),this.nativeEl.defaultMuted&&(this.nativeEl.muted=!0)},J=new WeakSet,Oe=function(e,o,c){let m=Object.getOwnPropertyNames(Object.getPrototypeOf(this)),g=nt(m,e),f=Object.getPrototypeOf(this.constructor).toString().indexOf("function HTMLElement")===0;g&&!f?typeof this[g]=="boolean"?c===null?this[g]=!1:this[g]=!0:this[g]=c:c===null?this.nativeEl.removeAttribute(e):["id","class"].indexOf(e)===-1&&this.nativeEl.setAttribute(e,c)};var ze=[],Je=Te.createElement("video",{is:"castable-video"}),at=["webkitDisplayingFullscreen","webkitSupportsFullscreen"];for(let a=Object.getPrototypeOf(Je);a&&a!==S.HTMLElement.prototype;a=Object.getPrototypeOf(a))Object.getOwnPropertyNames(a).forEach(s=>{at.indexOf(s)===-1&&ze.push(s)});ze.forEach(a=>{if(a in M.prototype)return;if(typeof Je[a]=="function")M.prototype[a]=function(){return this.nativeEl[a].apply(this.nativeEl,arguments)};else{let e={get(){return this.nativeEl[a]}};a!==a.toUpperCase()&&(e.set=function(o){this.nativeEl[a]=o}),Object.defineProperty(M.prototype,a,e)}});function nt(a,s){let e=null;return a.forEach(o=>{o.toLowerCase()==s.toLowerCase()&&(e=o)}),e}S.customElements.get("custom-video")||(S.customElements.define("custom-video",M),S.CustomVideoElement=M);var Ie=M;var n={BEACON_COLLECTION_DOMAIN:"beacon-collection-domain",CUSTOM_DOMAIN:"custom-domain",DEBUG:"debug",DISABLE_COOKIES:"disable-cookies",ENV_KEY:"env-key",MAX_RESOLUTION:"max-resolution",METADATA_URL:"metadata-url",PLAYBACK_ID:"playback-id",PLAYER_SOFTWARE_NAME:"player-software-name",PLAYER_SOFTWARE_VERSION:"player-software-version",PREFER_CMCD:"prefer-cmcd",PREFER_PLAYBACK:"prefer-playback",START_TIME:"start-time",STREAM_TYPE:"stream-type",TARGET_LIVE_WINDOW:"target-live-window",LIVE_EDGE_OFFSET:"live-edge-offset",TYPE:"type"},At=Object.values(n),vt=Ye(),Pt="mux-video",O,U,Q,Y,ee,te,se,ie,Le,Z=class extends Ie{constructor(){super();u(this,ie);u(this,O,void 0);u(this,U,void 0);u(this,Q,void 0);u(this,Y,{});u(this,ee,void 0);u(this,te,void 0);u(this,se,void 0);l(this,Q,ut())}static get observedAttributes(){var e;return[...At,...(e=Ie.observedAttributes)!=null?e:[]]}get preferCmcd(){var e;return(e=this.getAttribute(n.PREFER_CMCD))!=null?e:void 0}set preferCmcd(e){e!==this.preferCmcd&&(e?Ze.includes(e)?this.setAttribute(n.PREFER_CMCD,e):console.warn(`Invalid value for preferCmcd. Must be one of ${Ze.join()}`):this.removeAttribute(n.PREFER_CMCD))}get playerInitTime(){return i(this,Q)}get playerSoftwareName(){var e;return(e=i(this,te))!=null?e:Pt}set playerSoftwareName(e){l(this,te,e)}get playerSoftwareVersion(){var e;return(e=i(this,ee))!=null?e:vt}set playerSoftwareVersion(e){l(this,ee,e)}get _hls(){var e;return(e=i(this,O))==null?void 0:e.engine}get mux(){return this.nativeEl.mux}get error(){var e;return(e=dt(this.nativeEl))!=null?e:null}get errorTranslator(){return i(this,se)}set errorTranslator(e){l(this,se,e)}get src(){return this.getAttribute("src")}set src(e){e!==this.src&&(e==null?this.removeAttribute("src"):this.setAttribute("src",e))}get type(){var e;return(e=this.getAttribute(n.TYPE))!=null?e:void 0}set type(e){e!==this.type&&(e?this.setAttribute(n.TYPE,e):this.removeAttribute(n.TYPE))}get autoplay(){let e=this.getAttribute("autoplay");return e===null?!1:e===""?!0:e}set autoplay(e){let o=this.autoplay;e!==o&&(e?this.setAttribute("autoplay",typeof e=="string"?e:""):this.removeAttribute("autoplay"))}get preload(){let e=this.getAttribute("preload");return e===""?"auto":["none","metadata","auto"].includes(e)?e:super.preload}set preload(e){e!=this.getAttribute("preload")&&(["","none","metadata","auto"].includes(e)?this.setAttribute("preload",e):this.removeAttribute("preload"))}get debug(){return this.getAttribute(n.DEBUG)!=null}set debug(e){e!==this.debug&&(e?this.setAttribute(n.DEBUG,""):this.removeAttribute(n.DEBUG))}get disableCookies(){return this.hasAttribute(n.DISABLE_COOKIES)}set disableCookies(e){e!==this.disableCookies&&(e?this.setAttribute(n.DISABLE_COOKIES,""):this.removeAttribute(n.DISABLE_COOKIES))}get startTime(){let e=this.getAttribute(n.START_TIME);if(e==null)return;let o=+e;return Number.isNaN(o)?void 0:o}set startTime(e){e!==this.startTime&&(e==null?this.removeAttribute(n.START_TIME):this.setAttribute(n.START_TIME,`${e}`))}get playbackId(){var e;return(e=this.getAttribute(n.PLAYBACK_ID))!=null?e:void 0}set playbackId(e){e!==this.playbackId&&(e?this.setAttribute(n.PLAYBACK_ID,e):this.removeAttribute(n.PLAYBACK_ID))}get maxResolution(){var e;return(e=this.getAttribute(n.MAX_RESOLUTION))!=null?e:void 0}set maxResolution(e){e!==this.maxResolution&&(e?this.setAttribute(n.MAX_RESOLUTION,e):this.removeAttribute(n.MAX_RESOLUTION))}get customDomain(){var e;return(e=this.getAttribute(n.CUSTOM_DOMAIN))!=null?e:void 0}set customDomain(e){e!==this.customDomain&&(e?this.setAttribute(n.CUSTOM_DOMAIN,e):this.removeAttribute(n.CUSTOM_DOMAIN))}get envKey(){var e;return(e=this.getAttribute(n.ENV_KEY))!=null?e:void 0}set envKey(e){e!==this.envKey&&(e?this.setAttribute(n.ENV_KEY,e):this.removeAttribute(n.ENV_KEY))}get beaconCollectionDomain(){var e;return(e=this.getAttribute(n.BEACON_COLLECTION_DOMAIN))!=null?e:void 0}set beaconCollectionDomain(e){e!==this.beaconCollectionDomain&&(e?this.setAttribute(n.BEACON_COLLECTION_DOMAIN,e):this.removeAttribute(n.BEACON_COLLECTION_DOMAIN))}get streamType(){var e;return(e=this.getAttribute(n.STREAM_TYPE))!=null?e:yt(this.nativeEl)}set streamType(e){e!==this.streamType&&(e?this.setAttribute(n.STREAM_TYPE,e):this.removeAttribute(n.STREAM_TYPE))}get targetLiveWindow(){return this.hasAttribute(n.TARGET_LIVE_WINDOW)?+this.getAttribute(n.TARGET_LIVE_WINDOW):gt(this.nativeEl)}set targetLiveWindow(e){e!=this.targetLiveWindow&&(e==null?this.removeAttribute(n.TARGET_LIVE_WINDOW):this.setAttribute(n.TARGET_LIVE_WINDOW,`${+e}`))}get liveEdgeStart(){var e,o;if(this.hasAttribute(n.LIVE_EDGE_OFFSET)){let{liveEdgeOffset:c}=this,m=(e=this.nativeEl.seekable.end(0))!=null?e:0,g=(o=this.nativeEl.seekable.start(0))!=null?o:0;return Math.max(g,m-c)}return bt(this.nativeEl)}get liveEdgeOffset(){if(!!this.hasAttribute(n.LIVE_EDGE_OFFSET))return+this.getAttribute(n.LIVE_EDGE_OFFSET)}set liveEdgeOffset(e){e!=this.targetLiveWindow&&(e==null?this.removeAttribute(n.LIVE_EDGE_OFFSET):this.setAttribute(n.LIVE_EDGE_OFFSET,`${+e}`))}get seekable(){return Tt(this.nativeEl)}async addCuePoints(e){return ht(this.nativeEl,e)}get activeCuePoint(){return Et(this.nativeEl)}get cuePoints(){return mt(this.nativeEl)}getStartDate(){return ft(this.nativeEl,this._hls)}get currentPdt(){return pt(this.nativeEl,this._hls)}get preferPlayback(){let e=this.getAttribute(n.PREFER_PLAYBACK);if(e===Ee.MSE||e===Ee.NATIVE)return e}set preferPlayback(e){e!==this.preferPlayback&&(e===Ee.MSE||e===Ee.NATIVE?this.setAttribute(n.PREFER_PLAYBACK,e):this.removeAttribute(n.PREFER_PLAYBACK))}get metadata(){return{...this.getAttributeNames().filter(o=>o.startsWith("metadata-")&&![n.METADATA_URL].includes(o)).reduce((o,c)=>{let m=this.getAttribute(c);return m!=null&&(o[c.replace(/^metadata-/,"").replace(/-/g,"_")]=m),o},{}),...i(this,Y)}}set metadata(e){l(this,Y,e!=null?e:{}),this.mux&&this.mux.emit("hb",i(this,Y))}load(){l(this,O,ot(this,this.nativeEl,i(this,O)))}unload(){ct(this.nativeEl,i(this,O)),l(this,O,void 0)}attributeChangedCallback(e,o,c){var m,g;switch(super.attributeChangedCallback(e,o,c),e){case n.PLAYER_SOFTWARE_NAME:this.playerSoftwareName=c!=null?c:void 0;break;case n.PLAYER_SOFTWARE_VERSION:this.playerSoftwareVersion=c!=null?c:void 0;break;case"src":{let f=!!o,fe=!!c;!f&&fe?h(this,ie,Le).call(this):f&&!fe?this.unload():f&&fe&&(this.unload(),h(this,ie,Le).call(this));break}case"autoplay":if(c===o)break;(m=i(this,O))==null||m.setAutoplay(this.autoplay);break;case"preload":if(c===o)break;(g=i(this,O))==null||g.setPreload(c);break;case n.PLAYBACK_ID:this.src=lt(c!=null?c:void 0,{maxResolution:this.maxResolution,domain:this.customDomain});break;case n.DEBUG:{let f=this.debug;this.mux&&console.info("Cannot toggle debug mode of mux data after initialization. Make sure you set all metadata to override before setting the src."),this._hls&&(this._hls.config.debug=f);break}case n.METADATA_URL:c&&fetch(c).then(f=>f.json()).then(f=>this.metadata=f).catch(()=>console.error(`Unable to load or parse metadata JSON from metadata-url ${c}!`));break;case n.STREAM_TYPE:(c==null||c!==o)&&this.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}));break;case n.TARGET_LIVE_WINDOW:(c==null||c!==o)&&this.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0,detail:this.targetLiveWindow}));break;default:break}}disconnectedCallback(){this.unload()}};O=new WeakMap,U=new WeakMap,Q=new WeakMap,Y=new WeakMap,ee=new WeakMap,te=new WeakMap,se=new WeakMap,ie=new WeakSet,Le=async function(){i(this,U)||(await l(this,U,Promise.resolve()),l(this,U,null),this.load())};S.customElements.get("mux-video")||(S.customElements.define("mux-video",Z),S.MuxVideoElement=Z);var Kt=Z;export{n as Attributes,Yt as MediaError,$e as VideoEvents,Kt as default};
|
|
23
|
+
video {
|
|
24
|
+
max-width: 100%;
|
|
25
|
+
max-height: 100%;
|
|
26
|
+
min-width: 100%;
|
|
27
|
+
min-height: 100%;
|
|
28
|
+
object-fit: var(--media-object-fit, contain);
|
|
29
|
+
object-position: var(--media-object-position, 50% 50%);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
video::-webkit-media-text-track-container {
|
|
33
|
+
transform: var(--media-webkit-text-track-transform);
|
|
34
|
+
transition: var(--media-webkit-text-track-transition);
|
|
35
|
+
}
|
|
36
|
+
</style>
|
|
37
|
+
<slot></slot>
|
|
38
|
+
`);var yt=(o,{tag:s,is:t})=>{var M,P,S,C,te,j,L,N,V,nt,ee,ct,se;let u=(M=globalThis.document)==null?void 0:M.createElement(s,{is:t}),l=u?le(u):[];return P=class extends o{constructor(){super();n(this,N);n(this,nt);n(this,ct);n(this,j,void 0);n(this,L,void 0);this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.append(this.constructor.template.content.cloneNode(!0)))}static get observedAttributes(){var c,p,g;return f(c=P,C,te).call(c),[...(g=(p=u==null?void 0:u.constructor)==null?void 0:p.observedAttributes)!=null?g:[],"autopictureinpicture","disablepictureinpicture","disableremoteplayback","autoplay","controls","controlslist","crossorigin","loop","muted","playsinline","poster","preload","src"]}get nativeEl(){var d,c;return(c=(d=i(this,L))!=null?d:this.shadowRoot.querySelector(s))!=null?c:this.querySelector(s)}set nativeEl(d){E(this,L,d)}get defaultMuted(){return this.hasAttribute("muted")}set defaultMuted(d){this.toggleAttribute("muted",Boolean(d))}get src(){return this.getAttribute("src")}set src(d){this.setAttribute("src",`${d}`)}get preload(){var d,c;return(c=this.getAttribute("preload"))!=null?c:(d=this.nativeEl)==null?void 0:d.preload}set preload(d){this.setAttribute("preload",`${d}`)}attributeChangedCallback(d,c,p){f(this,N,V).call(this),f(this,ct,se).call(this,d,c,p)}connectedCallback(){f(this,N,V).call(this)}},S=new WeakMap,C=new WeakSet,te=function(){if(i(this,S))return;E(this,S,!0);let d=new Set(this.observedAttributes);d.delete("muted");for(let c of l){if(c in this.prototype)continue;if(typeof u[c]=="function")this.prototype[c]=function(...g){return f(this,N,V).call(this),(()=>this.call?this.call(c,...g):this.nativeEl[c].apply(this.nativeEl,g))()};else{let g={get(){var m,A,I;f(this,N,V).call(this);let h=c.toLowerCase();if(d.has(h)){let B=this.getAttribute(h);return B===null?!1:B===""?!0:B}return(I=(m=this.get)==null?void 0:m.call(this,c))!=null?I:(A=this.nativeEl)==null?void 0:A[c]}};c!==c.toUpperCase()&&(g.set=function(h){f(this,N,V).call(this);let m=c.toLowerCase();if(d.has(m)){h===!0||h===!1||h==null?this.toggleAttribute(m,Boolean(h)):this.setAttribute(m,h);return}if(this.set){this.set(c,h);return}this.nativeEl[c]=h}),Object.defineProperty(this.prototype,c,g)}}},j=new WeakMap,L=new WeakMap,N=new WeakSet,V=function(){var p,g;if(i(this,j))return;if(E(this,j,!0),!this.nativeEl){let h=document.createElement(s,{is:t});h.part=s,this.shadowRoot.append(h)}this.nativeEl.muted=this.hasAttribute("muted");for(let h of l)f(this,nt,ee).call(this,h);let d=new Map,c=this.shadowRoot.querySelector("slot:not([name])");c==null||c.addEventListener("slotchange",()=>{let h=new Map(d);c.assignedElements().filter(m=>["track","source"].includes(m.localName)).forEach(m=>{var I,B;h.delete(m);let A=d.get(m);A||(A=m.cloneNode(),d.set(m,A)),(B=(I=this.nativeEl).append)==null||B.call(I,A)}),h.forEach(m=>m.remove())});for(let h of this.constructor.Events)(g=(p=this.shadowRoot).addEventListener)==null||g.call(p,h,m=>{m.target===this.nativeEl&&this.dispatchEvent(new CustomEvent(m.type,{detail:m.detail}))},!0)},nt=new WeakSet,ee=function(d){if(Object.prototype.hasOwnProperty.call(this,d)){let c=this[d];delete this[d],this[d]=c}},ct=new WeakSet,se=function(d,c,p){var g,h,m,A;["id","class"].includes(d)||(p===null?(h=(g=this.nativeEl).removeAttribute)==null||h.call(g,d):(A=(m=this.nativeEl).setAttribute)==null||A.call(m,d,p))},n(P,C),x(P,"Events",Lt),x(P,"template",s.endsWith("audio")?It:kt),n(P,S,void 0),P};function le(o){let s=[];for(let t=Object.getPrototypeOf(o);t&&t!==HTMLElement.prototype;t=Object.getPrototypeOf(t))s.push(...Object.getOwnPropertyNames(t));return s}var xe=globalThis.document?yt(HTMLElement,{tag:"video"}):class{},Ge=globalThis.document?yt(HTMLElement,{tag:"audio"}):class{};Lt.push("castchange","entercast","leavecast");var Rt=yt(Q.HTMLElement,{tag:"video",is:"castable-video"}),a={BEACON_COLLECTION_DOMAIN:"beacon-collection-domain",CUSTOM_DOMAIN:"custom-domain",DEBUG:"debug",DISABLE_COOKIES:"disable-cookies",ENV_KEY:"env-key",MAX_RESOLUTION:"max-resolution",METADATA_URL:"metadata-url",PLAYBACK_ID:"playback-id",PLAYER_SOFTWARE_NAME:"player-software-name",PLAYER_SOFTWARE_VERSION:"player-software-version",PREFER_CMCD:"prefer-cmcd",PREFER_PLAYBACK:"prefer-playback",START_TIME:"start-time",STREAM_TYPE:"stream-type",TARGET_LIVE_WINDOW:"target-live-window",LIVE_EDGE_OFFSET:"live-edge-offset",TYPE:"type"},Ce=Object.values(a),Oe=Kt(),Me="mux-video",w,K,et,H,st,it,rt,at,_t,tt=class extends Rt{constructor(){super();n(this,at);n(this,w,void 0);n(this,K,void 0);n(this,et,void 0);n(this,H,{});n(this,st,void 0);n(this,it,void 0);n(this,rt,void 0);E(this,et,me())}static get observedAttributes(){var t;return[...Ce,...(t=Rt.observedAttributes)!=null?t:[]]}get preferCmcd(){var t;return(t=this.getAttribute(a.PREFER_CMCD))!=null?t:void 0}set preferCmcd(t){t!==this.preferCmcd&&(t?ie.includes(t)?this.setAttribute(a.PREFER_CMCD,t):console.warn(`Invalid value for preferCmcd. Must be one of ${ie.join()}`):this.removeAttribute(a.PREFER_CMCD))}get playerInitTime(){return i(this,et)}get playerSoftwareName(){var t;return(t=i(this,it))!=null?t:Me}set playerSoftwareName(t){E(this,it,t)}get playerSoftwareVersion(){var t;return(t=i(this,st))!=null?t:Oe}set playerSoftwareVersion(t){E(this,st,t)}get _hls(){var t;return(t=i(this,w))==null?void 0:t.engine}get mux(){return this.nativeEl.mux}get error(){var t;return(t=fe(this.nativeEl))!=null?t:null}get errorTranslator(){return i(this,rt)}set errorTranslator(t){E(this,rt,t)}get src(){return this.getAttribute("src")}set src(t){t!==this.src&&(t==null?this.removeAttribute("src"):this.setAttribute("src",t))}get type(){var t;return(t=this.getAttribute(a.TYPE))!=null?t:void 0}set type(t){t!==this.type&&(t?this.setAttribute(a.TYPE,t):this.removeAttribute(a.TYPE))}get autoplay(){let t=this.getAttribute("autoplay");return t===null?!1:t===""?!0:t}set autoplay(t){let u=this.autoplay;t!==u&&(t?this.setAttribute("autoplay",typeof t=="string"?t:""):this.removeAttribute("autoplay"))}get preload(){let t=this.getAttribute("preload");return t===""?"auto":["none","metadata","auto"].includes(t)?t:super.preload}set preload(t){t!=this.getAttribute("preload")&&(["","none","metadata","auto"].includes(t)?this.setAttribute("preload",t):this.removeAttribute("preload"))}get debug(){return this.getAttribute(a.DEBUG)!=null}set debug(t){t!==this.debug&&(t?this.setAttribute(a.DEBUG,""):this.removeAttribute(a.DEBUG))}get disableCookies(){return this.hasAttribute(a.DISABLE_COOKIES)}set disableCookies(t){t!==this.disableCookies&&(t?this.setAttribute(a.DISABLE_COOKIES,""):this.removeAttribute(a.DISABLE_COOKIES))}get startTime(){let t=this.getAttribute(a.START_TIME);if(t==null)return;let u=+t;return Number.isNaN(u)?void 0:u}set startTime(t){t!==this.startTime&&(t==null?this.removeAttribute(a.START_TIME):this.setAttribute(a.START_TIME,`${t}`))}get playbackId(){var t;return(t=this.getAttribute(a.PLAYBACK_ID))!=null?t:void 0}set playbackId(t){t!==this.playbackId&&(t?this.setAttribute(a.PLAYBACK_ID,t):this.removeAttribute(a.PLAYBACK_ID))}get maxResolution(){var t;return(t=this.getAttribute(a.MAX_RESOLUTION))!=null?t:void 0}set maxResolution(t){t!==this.maxResolution&&(t?this.setAttribute(a.MAX_RESOLUTION,t):this.removeAttribute(a.MAX_RESOLUTION))}get customDomain(){var t;return(t=this.getAttribute(a.CUSTOM_DOMAIN))!=null?t:void 0}set customDomain(t){t!==this.customDomain&&(t?this.setAttribute(a.CUSTOM_DOMAIN,t):this.removeAttribute(a.CUSTOM_DOMAIN))}get envKey(){var t;return(t=this.getAttribute(a.ENV_KEY))!=null?t:void 0}set envKey(t){t!==this.envKey&&(t?this.setAttribute(a.ENV_KEY,t):this.removeAttribute(a.ENV_KEY))}get beaconCollectionDomain(){var t;return(t=this.getAttribute(a.BEACON_COLLECTION_DOMAIN))!=null?t:void 0}set beaconCollectionDomain(t){t!==this.beaconCollectionDomain&&(t?this.setAttribute(a.BEACON_COLLECTION_DOMAIN,t):this.removeAttribute(a.BEACON_COLLECTION_DOMAIN))}get streamType(){var t;return(t=this.getAttribute(a.STREAM_TYPE))!=null?t:Te(this.nativeEl)}set streamType(t){t!==this.streamType&&(t?this.setAttribute(a.STREAM_TYPE,t):this.removeAttribute(a.STREAM_TYPE))}get targetLiveWindow(){return this.hasAttribute(a.TARGET_LIVE_WINDOW)?+this.getAttribute(a.TARGET_LIVE_WINDOW):ve(this.nativeEl)}set targetLiveWindow(t){t!=this.targetLiveWindow&&(t==null?this.removeAttribute(a.TARGET_LIVE_WINDOW):this.setAttribute(a.TARGET_LIVE_WINDOW,`${+t}`))}get liveEdgeStart(){var t,u;if(this.hasAttribute(a.LIVE_EDGE_OFFSET)){let{liveEdgeOffset:l}=this,M=(t=this.nativeEl.seekable.end(0))!=null?t:0,P=(u=this.nativeEl.seekable.start(0))!=null?u:0;return Math.max(P,M-l)}return Se(this.nativeEl)}get liveEdgeOffset(){if(!!this.hasAttribute(a.LIVE_EDGE_OFFSET))return+this.getAttribute(a.LIVE_EDGE_OFFSET)}set liveEdgeOffset(t){t!=this.targetLiveWindow&&(t==null?this.removeAttribute(a.LIVE_EDGE_OFFSET):this.setAttribute(a.LIVE_EDGE_OFFSET,`${+t}`))}get seekable(){return Pe(this.nativeEl)}async addCuePoints(t){return pe(this.nativeEl,t)}get activeCuePoint(){return ge(this.nativeEl)}get cuePoints(){return ye(this.nativeEl)}getStartDate(){return be(this.nativeEl,this._hls)}get currentPdt(){return Ae(this.nativeEl,this._hls)}get preferPlayback(){let t=this.getAttribute(a.PREFER_PLAYBACK);if(t===gt.MSE||t===gt.NATIVE)return t}set preferPlayback(t){t!==this.preferPlayback&&(t===gt.MSE||t===gt.NATIVE?this.setAttribute(a.PREFER_PLAYBACK,t):this.removeAttribute(a.PREFER_PLAYBACK))}get metadata(){return{...this.getAttributeNames().filter(u=>u.startsWith("metadata-")&&![a.METADATA_URL].includes(u)).reduce((u,l)=>{let M=this.getAttribute(l);return M!=null&&(u[l.replace(/^metadata-/,"").replace(/-/g,"_")]=M),u},{}),...i(this,H)}}set metadata(t){E(this,H,t!=null?t:{}),this.mux&&this.mux.emit("hb",i(this,H))}load(){E(this,w,de(this,this.nativeEl,i(this,w)))}unload(){he(this.nativeEl,i(this,w)),E(this,w,void 0)}attributeChangedCallback(t,u,l){var P,S;switch(Rt.observedAttributes.includes(t)&&!["src","autoplay","preload"].includes(t)&&super.attributeChangedCallback(t,u,l),t){case a.PLAYER_SOFTWARE_NAME:this.playerSoftwareName=l!=null?l:void 0;break;case a.PLAYER_SOFTWARE_VERSION:this.playerSoftwareVersion=l!=null?l:void 0;break;case"src":{let C=!!u,T=!!l;!C&&T?f(this,at,_t).call(this):C&&!T?this.unload():C&&T&&(this.unload(),f(this,at,_t).call(this));break}case"autoplay":if(l===u)break;(P=i(this,w))==null||P.setAutoplay(this.autoplay);break;case"preload":if(l===u)break;(S=i(this,w))==null||S.setPreload(l);break;case a.PLAYBACK_ID:this.src=Ee(l!=null?l:void 0,{maxResolution:this.maxResolution,domain:this.customDomain});break;case a.DEBUG:{let C=this.debug;this.mux&&console.info("Cannot toggle debug mode of mux data after initialization. Make sure you set all metadata to override before setting the src."),this._hls&&(this._hls.config.debug=C);break}case a.METADATA_URL:l&&fetch(l).then(C=>C.json()).then(C=>this.metadata=C).catch(()=>console.error(`Unable to load or parse metadata JSON from metadata-url ${l}!`));break;case a.STREAM_TYPE:(l==null||l!==u)&&this.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}));break;case a.TARGET_LIVE_WINDOW:(l==null||l!==u)&&this.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0,detail:this.targetLiveWindow}));break;default:break}}disconnectedCallback(){this.unload()}};w=new WeakMap,K=new WeakMap,et=new WeakMap,H=new WeakMap,st=new WeakMap,it=new WeakMap,rt=new WeakMap,at=new WeakSet,_t=async function(){i(this,K)||(await E(this,K,Promise.resolve()),E(this,K,null),this.load())};Q.customElements.get("mux-video")||(Q.customElements.define("mux-video",tt),Q.MuxVideoElement=tt);var Ze=tt;export{a as Attributes,$e as MediaError,Lt as VideoEvents,Ze as default};
|
|
27
39
|
//# sourceMappingURL=index.mjs.map
|