/*! * artplayer-plugin-chromecast.js v1.0.1 * Github: https://github.com/zhw2590582/ArtPlayer * (c) 2017-2025 Harvey Zack * Released under the MIT License. */ !function(e,t,o,n,r,i,a,c){var s="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},d="function"==typeof s[n]&&s[n],l=d.i||{},u=d.cache||{},f="undefined"!=typeof module&&"function"==typeof module.require&&module.require.bind(module);function w(t,o){if(!u[t]){if(!e[t]){if(r[t])return r[t];var i="function"==typeof s[n]&&s[n];if(!o&&i)return i(t,!0);if(d)return d(t,!0);if(f&&"string"==typeof t)return f(t);var a=Error("Cannot find module '"+t+"'");throw a.code="MODULE_NOT_FOUND",a}l.resolve=function(o){var n=e[t][1][o];return null!=n?n:o},l.cache={};var c=u[t]=new w.Module(t);e[t][0].call(c.exports,l,c,c.exports,s)}return u[t].exports;function l(e){var t=l.resolve(e);return!1===t?{}:w(t)}}w.isParcelRequire=!0,w.Module=function(e){this.id=e,this.bundle=w,this.require=f,this.exports={}},w.modules=e,w.cache=u,w.parent=d,w.distDir=void 0,w.publicUrl=void 0,w.devServer=void 0,w.i=l,w.register=function(t,o){e[t]=[function(e,t){t.exports=o},{}]},Object.defineProperty(w,"root",{get:function(){return s[n]}}),s[n]=w;for(var p=0;p{let t=document.querySelector(".art-icon-cast");if(t)switch(e){case"connected":t.style.color="red";break;case"connecting":case"disconnecting":t.style.color="orange";break;default:t.style.color="white"}},i=(t,o)=>{let n=e.url||t.option.url,r=new window.chrome.cast.media.MediaInfo(n,e.mimeType||({mp4:"video/mp4",webm:"video/webm",ogg:"video/ogg",ogv:"video/ogg",mp3:"audio/mp3",wav:"audio/wav",flv:"video/x-flv",mov:"video/quicktime",avi:"video/x-msvideo",wmv:"video/x-ms-wmv",mpd:"application/dash+xml",m3u8:"application/x-mpegURL"})[n.split("?")[0].split("#")[0].split(".").pop().toLowerCase()]||"application/octet-stream"),i=new window.chrome.cast.media.LoadRequest(r);o.loadMedia(i).then(()=>{t.notice.show="Casting started",e.onCastStart?.()}).catch(o=>{throw t.notice.show="Error casting media",e.onError?.(o),o})};return async a=>(a.controls.add({name:"chromecast",position:"right",tooltip:"Chromecast",html:`${e.icon||''}`,click:async()=>{if(!t)try{await new Promise((i,a)=>{var c;window.__onGCastApiAvailable=c=>{if(c){let a=window.cast.framework.CastContext.getInstance();a.setOptions({receiverApplicationId:window.chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID,autoJoinPolicy:window.chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED}),a.addEventListener(window.cast.framework.CastContextEventType.SESSION_STATE_CHANGED,t=>{let i=window.cast.framework.SessionState;switch(n=t.sessionState,o=t.session,t.sessionState){case i.NO_SESSION:e.onStateChange?.("disconnected"),r("disconnected");break;case i.SESSION_STARTING:e.onStateChange?.("connecting"),r("connecting");break;case i.SESSION_STARTED:e.onStateChange?.("connected"),r("connected");break;case i.SESSION_ENDING:e.onStateChange?.("disconnecting"),r("disconnecting");break;case i.SESSION_RESUMED:e.onStateChange?.("connected"),r("connected")}}),a.addEventListener(window.cast.framework.CastContextEventType.CAST_STATE_CHANGED,t=>{let o=window.cast.framework.CastState;switch(t.castState){case o.NO_DEVICES_AVAILABLE:e.onCastAvailable?.(!1);break;case o.NOT_CONNECTED:case o.CONNECTING:case o.CONNECTED:e.onCastAvailable?.(!0)}}),t=!0,i()}else a(Error("Cast API is not available"))},window.chrome&&window.chrome.cast||(c=e.sdk||"https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1",new Promise((e,t)=>{let o=document.createElement("script");o.src=c,o.onload=e,o.onerror=t,document.body.appendChild(o)})).catch(a)})}catch(t){throw a.notice.show="Failed to initialize Cast API",e.onError?.(t),t}let c=window.cast.framework.CastContext.getInstance();if(o)i(a,o);else try{let e=await c.requestSession();i(a,e)}catch(t){throw a.notice.show="Error connecting to cast session",e.onError?.(t),t}}}),{name:"artplayerPluginChromecast",getCastState:()=>n,isCasting:()=>null!==o})}r.defineInteropFlag(o),r.export(o,"default",()=>i),"undefined"!=typeof window&&(window.artplayerPluginChromecast=i)},{"@parcel/transformer-js/src/esmodule-helpers.js":"6ykb1"}],"6ykb1":[function(e,t,o,n){o.interopDefault=function(e){return e&&e.__esModule?e:{default:e}},o.defineInteropFlag=function(e){Object.defineProperty(e,"__esModule",{value:!0})},o.exportAll=function(e,t){return Object.keys(e).forEach(function(o){"default"===o||"__esModule"===o||Object.prototype.hasOwnProperty.call(t,o)||Object.defineProperty(t,o,{enumerable:!0,get:function(){return e[o]}})}),t},o.export=function(e,t,o){Object.defineProperty(e,t,{enumerable:!0,get:o})}},{}]},["18Aaf"],"18Aaf","parcelRequire4dc0",{});