Files
ArtPlayer/docs/compiled/artplayer-plugin-chromecast.mjs.map
T
Harvey Zack c911928166 feat: add danmuku plugin documentation and i18n setup
- Created a new documentation file for the danmuku plugin with interactive code execution.
- Added comprehensive i18n setup instructions, including default language settings, language imports, and examples for adding and modifying languages.
- Introduced a test file to verify the integration of the danmuku plugin.
2025-08-17 12:09:50 +08:00

1 line
27 KiB
Plaintext

{"mappings":"C,A,S,C,C,C,C,C,C,C,C,C,C,C,C,C,C,C,E,I,E,A,a,O,W,W,A,a,O,K,K,A,a,O,O,O,A,a,O,O,O,C,E,E,A,Y,O,C,C,E,E,C,C,E,C,E,E,C,E,C,E,E,E,K,E,C,E,E,A,a,O,Q,A,Y,O,O,O,E,O,O,C,I,C,Q,S,E,C,C,C,E,G,C,C,C,E,C,C,G,C,C,C,E,C,C,G,C,C,E,C,O,C,C,E,C,I,E,A,Y,O,C,C,E,E,C,C,E,C,G,C,G,E,O,E,E,C,G,G,E,O,E,E,C,G,G,G,A,U,O,E,O,E,G,I,E,A,M,uB,E,I,O,E,I,C,mB,C,C,E,O,C,S,C,E,I,E,C,C,E,C,E,C,E,C,O,A,M,E,E,C,E,E,K,C,C,E,I,E,C,C,E,C,I,E,M,C,G,C,C,E,C,E,C,I,C,E,O,C,E,E,E,O,C,E,C,O,C,C,E,C,O,C,S,E,C,E,I,E,E,O,C,G,M,A,C,I,E,C,E,E,E,C,C,E,e,C,C,E,E,M,C,S,C,E,I,C,E,C,E,I,C,M,C,E,I,C,O,C,E,I,C,O,C,C,C,E,E,O,C,E,E,K,C,E,E,M,C,E,E,O,C,K,E,E,S,C,K,E,E,S,C,K,E,E,C,C,E,E,Q,C,S,C,C,C,E,C,C,E,C,C,S,C,C,C,E,E,O,C,C,E,C,E,A,E,O,c,C,E,O,C,I,W,O,C,C,E,A,C,G,C,C,E,C,E,I,I,E,E,E,E,M,C,I,E,C,C,E,E,G,E,C,I,E,E,E,A,C,U,O,S,A,a,O,O,O,O,C,E,A,Y,O,Q,O,G,E,O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AAS,CAAC,CAC5C,EAEA,EAAQ,iBAAiB,CAAG,SAAU,CAAC,EACrC,OAAO,cAAc,CAAC,EAAG,aAAc,CAAC,MAAO,CAAA,CAAI,EACrD,EAEA,EAAQ,SAAS,CAAG,SAAU,CAAM,CAAE,CAAI,EAkBxC,OAjBA,OAAO,IAAI,CAAC,GAAQ,OAAO,CAAC,SAAU,CAAG,EAE7B,YAAR,GACA,AAAQ,eAAR,GACA,OAAO,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,EAAM,IAK7C,OAAO,cAAc,CAAC,EAAM,EAAK,CAC/B,WAAY,CAAA,EACZ,IAAK,WACH,OAAO,CAAM,CAAC,EAAI,AACpB,CACF,EACF,GAEO,CACT,EAEA,EAAQ,MAAM,CAAG,SAAU,CAAI,CAAE,CAAQ,CAAE,CAAG,EAC5C,OAAO,cAAc,CAAC,EAAM,EAAU,CACpC,WAAY,CAAA,EACZ,IAAK,CACP,EACF,C,E,C,E,E,C,Q,C,Q,oB,C,G,G,C,Q,C,C,C,kB,gB,K,O","sources":["<anon>","packages/artplayer-plugin-chromecast/src/index.js","node_modules/@parcel/transformer-js/src/esmodule-helpers.js"],"sourcesContent":["// modules are defined as an array\n// [ module function, map of requires ]\n//\n// map of requires is short require name -> numeric require\n//\n// anything defined in a previous bundle is accessed via the\n// orig method which is the require for previous bundles\n\n(function (\n modules,\n entry,\n mainEntry,\n parcelRequireName,\n externals,\n distDir,\n publicUrl,\n devServer\n) {\n /* eslint-disable no-undef */\n var globalObject =\n typeof globalThis !== 'undefined'\n ? globalThis\n : typeof self !== 'undefined'\n ? self\n : typeof window !== 'undefined'\n ? window\n : typeof global !== 'undefined'\n ? global\n : {};\n /* eslint-enable no-undef */\n\n // Save the require from previous bundle to this closure if any\n var previousRequire =\n typeof globalObject[parcelRequireName] === 'function' &&\n globalObject[parcelRequireName];\n\n var importMap = previousRequire.i || {};\n var cache = previousRequire.cache || {};\n // Do not use `require` to prevent Webpack from trying to bundle this call\n var nodeRequire =\n typeof module !== 'undefined' &&\n typeof module.require === 'function' &&\n module.require.bind(module);\n\n function newRequire(name, jumped) {\n if (!cache[name]) {\n if (!modules[name]) {\n if (externals[name]) {\n return externals[name];\n }\n // if we cannot find the module within our internal map or\n // cache jump to the current global require ie. the last bundle\n // that was added to the page.\n var currentRequire =\n typeof globalObject[parcelRequireName] === 'function' &&\n globalObject[parcelRequireName];\n if (!jumped && currentRequire) {\n return currentRequire(name, true);\n }\n\n // If there are other bundles on this page the require from the\n // previous one is saved to 'previousRequire'. Repeat this as\n // many times as there are bundles until the module is found or\n // we exhaust the require chain.\n if (previousRequire) {\n return previousRequire(name, true);\n }\n\n // Try the node require function if it exists.\n if (nodeRequire && typeof name === 'string') {\n return nodeRequire(name);\n }\n\n var err = new Error(\"Cannot find module '\" + name + \"'\");\n err.code = 'MODULE_NOT_FOUND';\n throw err;\n }\n\n localRequire.resolve = resolve;\n localRequire.cache = {};\n\n var module = (cache[name] = new newRequire.Module(name));\n\n modules[name][0].call(\n module.exports,\n localRequire,\n module,\n module.exports,\n globalObject\n );\n }\n\n return cache[name].exports;\n\n function localRequire(x) {\n var res = localRequire.resolve(x);\n return res === false ? {} : newRequire(res);\n }\n\n function resolve(x) {\n var id = modules[name][1][x];\n return id != null ? id : x;\n }\n }\n\n function Module(moduleName) {\n this.id = moduleName;\n this.bundle = newRequire;\n this.require = nodeRequire;\n this.exports = {};\n }\n\n newRequire.isParcelRequire = true;\n newRequire.Module = Module;\n newRequire.modules = modules;\n newRequire.cache = cache;\n newRequire.parent = previousRequire;\n newRequire.distDir = distDir;\n newRequire.publicUrl = publicUrl;\n newRequire.devServer = devServer;\n newRequire.i = importMap;\n newRequire.register = function (id, exports) {\n modules[id] = [\n function (require, module) {\n module.exports = exports;\n },\n {},\n ];\n };\n\n // Only insert newRequire.load when it is actually used.\n // The code in this file is linted against ES5, so dynamic import is not allowed.\n // INSERT_LOAD_HERE\n\n Object.defineProperty(newRequire, 'root', {\n get: function () {\n return globalObject[parcelRequireName];\n },\n });\n\n globalObject[parcelRequireName] = newRequire;\n\n for (var i = 0; i < entry.length; i++) {\n newRequire(entry[i]);\n }\n\n if (mainEntry) {\n // Expose entry point to Node, AMD or browser globals\n // Based on https://github.com/ForbesLindesay/umd/blob/master/template.js\n var mainExports = newRequire(mainEntry);\n\n // CommonJS\n if (typeof exports === 'object' && typeof module !== 'undefined') {\n module.exports = mainExports;\n\n // RequireJS\n } else if (typeof define === 'function' && define.amd) {\n define(function () {\n return mainExports;\n });\n }\n }\n})({\"cv67D\":[function(require,module,exports,__globalThis) {\nvar parcelHelpers = require(\"@parcel/transformer-js/src/esmodule-helpers.js\");\nparcelHelpers.defineInteropFlag(exports);\nparcelHelpers.export(exports, \"default\", ()=>artplayerPluginChromecast);\nfunction loadScript(src) {\n return new Promise((resolve, reject)=>{\n const script = document.createElement('script');\n script.src = src;\n script.onload = resolve;\n script.onerror = reject;\n document.body.appendChild(script);\n });\n}\nfunction getMimeType(url) {\n const extension = url.split('?')[0].split('#')[0].split('.').pop().toLowerCase();\n const mimeTypes = {\n mp4: 'video/mp4',\n webm: 'video/webm',\n ogg: 'video/ogg',\n ogv: 'video/ogg',\n mp3: 'audio/mp3',\n wav: 'audio/wav',\n flv: 'video/x-flv',\n mov: 'video/quicktime',\n avi: 'video/x-msvideo',\n wmv: 'video/x-ms-wmv',\n mpd: 'application/dash+xml',\n m3u8: 'application/x-mpegURL'\n };\n return mimeTypes[extension] || 'application/octet-stream';\n}\nfunction artplayerPluginChromecast(option) {\n const DEFAULT_ICON = `<svg height=\"20\" width=\"20\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 576 512\"><path d=\"M512 96H64v99c-13-2-26.4-3-40-3H0V96C0 60.7 28.7 32 64 32H512c35.3 0 64 28.7 64 64V416c0 35.3-28.7 64-64 64H288V456c0-13.6-1-27-3-40H512V96zM24 224c128.1 0 232 103.9 232 232c0 13.3-10.7 24-24 24s-24-10.7-24-24c0-101.6-82.4-184-184-184c-13.3 0-24-10.7-24-24s10.7-24 24-24zm8 192a32 32 0 1 1 0 64 32 32 0 1 1 0-64zM0 344c0-13.3 10.7-24 24-24c75.1 0 136 60.9 136 136c0 13.3-10.7 24-24 24s-24-10.7-24-24c0-48.6-39.4-88-88-88c-13.3 0-24-10.7-24-24z\"/></svg>`;\n const DEFAULT_SDK = 'https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1';\n let isCastInitialized = false;\n let castSession = null;\n let castState = null;\n const updateCastButton = (state)=>{\n const button = document.querySelector('.art-icon-cast');\n if (button) switch(state){\n case 'connected':\n button.style.color = 'red';\n break;\n case 'connecting':\n case 'disconnecting':\n button.style.color = 'orange';\n break;\n case 'disconnected':\n default:\n button.style.color = 'white';\n break;\n }\n };\n const initializeCastApi = ()=>{\n return new Promise((resolve, reject)=>{\n window.__onGCastApiAvailable = (isAvailable)=>{\n if (isAvailable) {\n const context = window.cast.framework.CastContext.getInstance();\n context.setOptions({\n receiverApplicationId: window.chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID,\n autoJoinPolicy: window.chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED\n });\n // Listen for session state changes\n context.addEventListener(window.cast.framework.CastContextEventType.SESSION_STATE_CHANGED, (event)=>{\n const SessionState = window.cast.framework.SessionState;\n castState = event.sessionState;\n castSession = event.session;\n switch(event.sessionState){\n case SessionState.NO_SESSION:\n option.onStateChange?.('disconnected');\n updateCastButton('disconnected');\n break;\n case SessionState.SESSION_STARTING:\n option.onStateChange?.('connecting');\n updateCastButton('connecting');\n break;\n case SessionState.SESSION_STARTED:\n option.onStateChange?.('connected');\n updateCastButton('connected');\n break;\n case SessionState.SESSION_ENDING:\n option.onStateChange?.('disconnecting');\n updateCastButton('disconnecting');\n break;\n case SessionState.SESSION_RESUMED:\n option.onStateChange?.('connected');\n updateCastButton('connected');\n break;\n }\n });\n // Listen for cast state changes\n context.addEventListener(window.cast.framework.CastContextEventType.CAST_STATE_CHANGED, (event)=>{\n const CastState = window.cast.framework.CastState;\n switch(event.castState){\n case CastState.NO_DEVICES_AVAILABLE:\n option.onCastAvailable?.(false);\n break;\n case CastState.NOT_CONNECTED:\n option.onCastAvailable?.(true);\n break;\n case CastState.CONNECTING:\n case CastState.CONNECTED:\n option.onCastAvailable?.(true);\n break;\n }\n });\n isCastInitialized = true;\n resolve();\n } else reject(new Error('Cast API is not available'));\n };\n if (!window.chrome || !window.chrome.cast) loadScript(option.sdk || DEFAULT_SDK).catch(reject);\n });\n };\n const castVideo = (art, session)=>{\n const url = option.url || art.option.url;\n const mediaInfo = new window.chrome.cast.media.MediaInfo(url, option.mimeType || getMimeType(url));\n const request = new window.chrome.cast.media.LoadRequest(mediaInfo);\n session.loadMedia(request).then(()=>{\n art.notice.show = 'Casting started';\n option.onCastStart?.();\n }).catch((error)=>{\n art.notice.show = 'Error casting media';\n option.onError?.(error);\n throw error;\n });\n };\n return async (art)=>{\n art.controls.add({\n name: 'chromecast',\n position: 'right',\n tooltip: 'Chromecast',\n html: `<i class=\"art-icon art-icon-cast\">${option.icon || DEFAULT_ICON}</i>`,\n click: async ()=>{\n if (!isCastInitialized) try {\n await initializeCastApi();\n } catch (error) {\n art.notice.show = 'Failed to initialize Cast API';\n option.onError?.(error);\n throw error;\n }\n const context = window.cast.framework.CastContext.getInstance();\n if (castSession) castVideo(art, castSession);\n else try {\n const session = await context.requestSession();\n castVideo(art, session);\n } catch (error) {\n art.notice.show = 'Error connecting to cast session';\n option.onError?.(error);\n throw error;\n }\n }\n });\n return {\n name: 'artplayerPluginChromecast',\n getCastState: ()=>castState,\n isCasting: ()=>castSession !== null\n };\n };\n}\nif (typeof window !== 'undefined') window.artplayerPluginChromecast = artplayerPluginChromecast;\n\n},{\"@parcel/transformer-js/src/esmodule-helpers.js\":\"5lQoW\"}],\"5lQoW\":[function(require,module,exports,__globalThis) {\nexports.interopDefault = function(a) {\n return a && a.__esModule ? a : {\n default: a\n };\n};\nexports.defineInteropFlag = function(a) {\n Object.defineProperty(a, '__esModule', {\n value: true\n });\n};\nexports.exportAll = function(source, dest) {\n Object.keys(source).forEach(function(key) {\n if (key === 'default' || key === '__esModule' || Object.prototype.hasOwnProperty.call(dest, key)) return;\n Object.defineProperty(dest, key, {\n enumerable: true,\n get: function() {\n return source[key];\n }\n });\n });\n return dest;\n};\nexports.export = function(dest, destName, get) {\n Object.defineProperty(dest, destName, {\n enumerable: true,\n get: get\n });\n};\n\n},{}]},[\"cv67D\"], \"cv67D\", \"parcelRequire4dc0\", {})\nlet {default: _default, } = parcelRequire4dc0(\"cv67D\");\nexport {_default as default, };\n\n//# sourceMappingURL=index.js.map\n","function loadScript(src) {\n return new Promise((resolve, reject) => {\n const script = document.createElement('script')\n script.src = src\n script.onload = resolve\n script.onerror = reject\n document.body.appendChild(script)\n })\n}\n\nfunction getMimeType(url) {\n const extension = url.split('?')[0].split('#')[0].split('.').pop().toLowerCase()\n const mimeTypes = {\n mp4: 'video/mp4',\n webm: 'video/webm',\n ogg: 'video/ogg',\n ogv: 'video/ogg',\n mp3: 'audio/mp3',\n wav: 'audio/wav',\n flv: 'video/x-flv',\n mov: 'video/quicktime',\n avi: 'video/x-msvideo',\n wmv: 'video/x-ms-wmv',\n mpd: 'application/dash+xml',\n m3u8: 'application/x-mpegURL',\n }\n return mimeTypes[extension] || 'application/octet-stream'\n}\n\nexport default function artplayerPluginChromecast(option) {\n const DEFAULT_ICON = `<svg height=\"20\" width=\"20\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 576 512\"><path d=\"M512 96H64v99c-13-2-26.4-3-40-3H0V96C0 60.7 28.7 32 64 32H512c35.3 0 64 28.7 64 64V416c0 35.3-28.7 64-64 64H288V456c0-13.6-1-27-3-40H512V96zM24 224c128.1 0 232 103.9 232 232c0 13.3-10.7 24-24 24s-24-10.7-24-24c0-101.6-82.4-184-184-184c-13.3 0-24-10.7-24-24s10.7-24 24-24zm8 192a32 32 0 1 1 0 64 32 32 0 1 1 0-64zM0 344c0-13.3 10.7-24 24-24c75.1 0 136 60.9 136 136c0 13.3-10.7 24-24 24s-24-10.7-24-24c0-48.6-39.4-88-88-88c-13.3 0-24-10.7-24-24z\"/></svg>`\n const DEFAULT_SDK = 'https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1'\n\n let isCastInitialized = false\n let castSession = null\n let castState = null\n\n const updateCastButton = (state) => {\n const button = document.querySelector('.art-icon-cast')\n if (button) {\n switch (state) {\n case 'connected':\n button.style.color = 'red'\n break\n case 'connecting':\n case 'disconnecting':\n button.style.color = 'orange'\n break\n case 'disconnected':\n default:\n button.style.color = 'white'\n break\n }\n }\n }\n\n const initializeCastApi = () => {\n return new Promise((resolve, reject) => {\n window.__onGCastApiAvailable = (isAvailable) => {\n if (isAvailable) {\n const context = window.cast.framework.CastContext.getInstance()\n context.setOptions({\n receiverApplicationId: window.chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID,\n autoJoinPolicy: window.chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED,\n })\n\n // Listen for session state changes\n context.addEventListener(\n window.cast.framework.CastContextEventType.SESSION_STATE_CHANGED,\n (event) => {\n const SessionState = window.cast.framework.SessionState\n castState = event.sessionState\n castSession = event.session\n\n switch (event.sessionState) {\n case SessionState.NO_SESSION:\n option.onStateChange?.('disconnected')\n updateCastButton('disconnected')\n break\n case SessionState.SESSION_STARTING:\n option.onStateChange?.('connecting')\n updateCastButton('connecting')\n break\n case SessionState.SESSION_STARTED:\n option.onStateChange?.('connected')\n updateCastButton('connected')\n break\n case SessionState.SESSION_ENDING:\n option.onStateChange?.('disconnecting')\n updateCastButton('disconnecting')\n break\n case SessionState.SESSION_RESUMED:\n option.onStateChange?.('connected')\n updateCastButton('connected')\n break\n }\n },\n )\n\n // Listen for cast state changes\n context.addEventListener(window.cast.framework.CastContextEventType.CAST_STATE_CHANGED, (event) => {\n const CastState = window.cast.framework.CastState\n switch (event.castState) {\n case CastState.NO_DEVICES_AVAILABLE:\n option.onCastAvailable?.(false)\n break\n case CastState.NOT_CONNECTED:\n option.onCastAvailable?.(true)\n break\n case CastState.CONNECTING:\n case CastState.CONNECTED:\n option.onCastAvailable?.(true)\n break\n }\n })\n\n isCastInitialized = true\n resolve()\n }\n else {\n reject(new Error('Cast API is not available'))\n }\n }\n if (!window.chrome || !window.chrome.cast) {\n loadScript(option.sdk || DEFAULT_SDK).catch(reject)\n }\n })\n }\n\n const castVideo = (art, session) => {\n const url = option.url || art.option.url\n const mediaInfo = new window.chrome.cast.media.MediaInfo(url, option.mimeType || getMimeType(url))\n const request = new window.chrome.cast.media.LoadRequest(mediaInfo)\n session\n .loadMedia(request)\n .then(() => {\n art.notice.show = 'Casting started'\n option.onCastStart?.()\n })\n .catch((error) => {\n art.notice.show = 'Error casting media'\n option.onError?.(error)\n throw error\n })\n }\n\n return async (art) => {\n art.controls.add({\n name: 'chromecast',\n position: 'right',\n tooltip: 'Chromecast',\n html: `<i class=\"art-icon art-icon-cast\">${option.icon || DEFAULT_ICON}</i>`,\n click: async () => {\n if (!isCastInitialized) {\n try {\n await initializeCastApi()\n }\n catch (error) {\n art.notice.show = 'Failed to initialize Cast API'\n option.onError?.(error)\n throw error\n }\n }\n\n const context = window.cast.framework.CastContext.getInstance()\n if (castSession) {\n castVideo(art, castSession)\n }\n else {\n try {\n const session = await context.requestSession()\n castVideo(art, session)\n }\n catch (error) {\n art.notice.show = 'Error connecting to cast session'\n option.onError?.(error)\n throw error\n }\n }\n },\n })\n\n return {\n name: 'artplayerPluginChromecast',\n getCastState: () => castState,\n isCasting: () => castSession !== null,\n }\n }\n}\n\nif (typeof window !== 'undefined') {\n window.artplayerPluginChromecast = artplayerPluginChromecast\n}\n","exports.interopDefault = function (a) {\n return a && a.__esModule ? a : {default: a};\n};\n\nexports.defineInteropFlag = function (a) {\n Object.defineProperty(a, '__esModule', {value: true});\n};\n\nexports.exportAll = function (source, dest) {\n Object.keys(source).forEach(function (key) {\n if (\n key === 'default' ||\n key === '__esModule' ||\n Object.prototype.hasOwnProperty.call(dest, key)\n ) {\n return;\n }\n\n Object.defineProperty(dest, key, {\n enumerable: true,\n get: function () {\n return source[key];\n },\n });\n });\n\n return dest;\n};\n\nexports.export = function (dest, destName, get) {\n Object.defineProperty(dest, destName, {\n enumerable: true,\n get: get,\n });\n};\n"],"names":["modules","entry","mainEntry","parcelRequireName","externals","distDir","publicUrl","devServer","globalObject","globalThis","self","window","global","previousRequire","importMap","i","cache","nodeRequire","module","require","bind","newRequire","name","jumped","currentRequire","err","Error","code","localRequire","resolve","x","id","Module","call","exports","res","isParcelRequire","moduleName","bundle","parent","register","Object","defineProperty","get","length","mainExports","define","amd","__globalThis","parcelHelpers","artplayerPluginChromecast","option","isCastInitialized","castSession","castState","updateCastButton","state","button","document","querySelector","style","color","castVideo","art","session","url","mediaInfo","chrome","cast","media","MediaInfo","mimeType","mimeTypes","mp4","webm","ogg","ogv","mp3","wav","flv","mov","avi","wmv","mpd","m3u8","split","pop","toLowerCase","request","LoadRequest","loadMedia","then","notice","show","onCastStart","catch","error","onError","controls","add","position","tooltip","html","icon","click","Promise","reject","src","__onGCastApiAvailable","isAvailable","context","framework","CastContext","getInstance","setOptions","receiverApplicationId","DEFAULT_MEDIA_RECEIVER_APP_ID","autoJoinPolicy","AutoJoinPolicy","ORIGIN_SCOPED","addEventListener","CastContextEventType","SESSION_STATE_CHANGED","event","SessionState","sessionState","NO_SESSION","onStateChange","SESSION_STARTING","SESSION_STARTED","SESSION_ENDING","SESSION_RESUMED","CAST_STATE_CHANGED","CastState","NO_DEVICES_AVAILABLE","onCastAvailable","NOT_CONNECTED","CONNECTING","CONNECTED","loadScript","sdk","script","createElement","onload","onerror","body","appendChild","requestSession","getCastState","isCasting","defineInteropFlag","export","interopDefault","a","__esModule","default","value","exportAll","source","dest","keys","forEach","key","prototype","hasOwnProperty","enumerable","destName","_default","parcelRequire4dc0"],"version":3,"file":"index.js.map"}