mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-08 10:56:15 -08:00
Refactor code structure for improved readability and maintainability
This commit is contained in:
1 parent
4a0fbda3c4
commit
0bb4e1acdb
214 files changed
+462
-415
No files matched your search
@@ -2,7 +2,7 @@
|
||||
/*!
|
||||
* artplayer-plugin-chromecast.js v1.0.1
|
||||
* Github: https://github.com/zhw2590582/ArtPlayer
|
||||
* (c) 2017-2025 Harvey Zack
|
||||
* (c) 2017-2026 Harvey Zack
|
||||
* Released under the MIT License.
|
||||
*/
|
||||
!function(e,t,r,n,o,i,c,a){var u="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},s="function"==typeof u[n]&&u[n],l=s.i||{},f=s.cache||{},p="undefined"!=typeof module&&"function"==typeof module.require&&module.require.bind(module);function d(t,r){if(!f[t]){if(!e[t]){if(o[t])return o[t];var i="function"==typeof u[n]&&u[n];if(!r&&i)return i(t,!0);if(s)return s(t,!0);if(p&&"string"==typeof t)return p(t);var c=Error("Cannot find module '"+t+"'");throw c.code="MODULE_NOT_FOUND",c}l.resolve=function(r){var n=e[t][1][r];return null!=n?n:r},l.cache={};var a=f[t]=new d.Module(t);e[t][0].call(a.exports,l,a,a.exports,u)}return f[t].exports;function l(e){var t=l.resolve(e);if(!1===t)return{};if(Array.isArray(t)){var r={__esModule:!0};return t.forEach(function(e){var t=e[0],n=e[1],o=e[2]||e[0],i=d(n);"*"===t?Object.keys(i).forEach(function(e){"default"===e||"__esModule"===e||Object.prototype.hasOwnProperty.call(r,e)||Object.defineProperty(r,e,{enumerable:!0,get:function(){return i[e]}})}):"*"===o?Object.defineProperty(r,t,{enumerable:!0,value:i}):Object.defineProperty(r,t,{enumerable:!0,get:function(){return"default"===o?i.__esModule?i.default:i:i[o]}})}),r}return d(t)}}d.isParcelRequire=!0,d.Module=function(e){this.id=e,this.bundle=d,this.require=p,this.exports={}},d.modules=e,d.cache=f,d.parent=s,d.distDir=void 0,d.publicUrl=void 0,d.devServer=void 0,d.i=l,d.register=function(t,r){e[t]=[function(e,t){t.exports=r},{}]},Object.defineProperty(d,"root",{get:function(){return u[n]}}),u[n]=d;for(var _=0;_<t.length;_++)d(t[_]);if(r){var y=d(r);"object"==typeof exports&&"undefined"!=typeof module?module.exports=y:"function"==typeof define&&define.amd&&define(function(){return y})}}({"1xnGs":[function(e,t,r,n){var o=e("@parcel/transformer-js/src/esmodule-helpers.js");o.defineInteropFlag(r),o.export(r,"default",function(){return a});var i=e("@swc/helpers/cjs/_async_to_generator.cjs"),c=e("@swc/helpers/cjs/_ts_generator.cjs");function a(e){var t=!1,r=null,n=null,o=function(e){var 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"}},a=function(t,r){var n=e.url||t.option.url,o=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(o);r.loadMedia(i).then(function(){var r;t.notice.show="Casting started",null==(r=e.onCastStart)||r.call(e)}).catch(function(r){var n;throw t.notice.show="Error casting media",null==(n=e.onError)||n.call(e,r),r})};return function(u){return(0,i._)(function(){return(0,c._)(this,function(s){return u.controls.add({name:"chromecast",position:"right",tooltip:"Chromecast",html:'<i class="art-icon art-icon-cast">'.concat(e.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>',"</i>"),click:function(){return(0,i._)(function(){var i,s,l,f,p;return(0,c._)(this,function(c){switch(c.label){case 0:if(t)return[3,4];c.label=1;case 1:return c.trys.push([1,3,,4]),[4,new Promise(function(i,c){var a;window.__onGCastApiAvailable=function(a){if(a){var u=window.cast.framework.CastContext.getInstance();u.setOptions({receiverApplicationId:window.chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID,autoJoinPolicy:window.chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED}),u.addEventListener(window.cast.framework.CastContextEventType.SESSION_STATE_CHANGED,function(t){var i,c,a,u,s,l=window.cast.framework.SessionState;switch(n=t.sessionState,r=t.session,t.sessionState){case l.NO_SESSION:null==(i=e.onStateChange)||i.call(e,"disconnected"),o("disconnected");break;case l.SESSION_STARTING:null==(c=e.onStateChange)||c.call(e,"connecting"),o("connecting");break;case l.SESSION_STARTED:null==(a=e.onStateChange)||a.call(e,"connected"),o("connected");break;case l.SESSION_ENDING:null==(u=e.onStateChange)||u.call(e,"disconnecting"),o("disconnecting");break;case l.SESSION_RESUMED:null==(s=e.onStateChange)||s.call(e,"connected"),o("connected")}}),u.addEventListener(window.cast.framework.CastContextEventType.CAST_STATE_CHANGED,function(t){var r,n,o,i=window.cast.framewoLine truncated
|
||||
!function(e,t,n,r,o,a,c,i){var s="u">typeof globalThis?globalThis:"u">typeof self?self:"u">typeof window?window:"u">typeof global?global:{},l="function"==typeof s[r]&&s[r],u=l.i||{},f=l.cache||{},d="u">typeof module&&"function"==typeof module.require&&module.require.bind(module);function p(t,n){if(!f[t]){if(!e[t]){if(o[t])return o[t];var a="function"==typeof s[r]&&s[r];if(!n&&a)return a(t,!0);if(l)return l(t,!0);if(d&&"string"==typeof t)return d(t);var c=Error("Cannot find module '"+t+"'");throw c.code="MODULE_NOT_FOUND",c}u.resolve=function(n){var r=e[t][1][n];return null!=r?r:n},u.cache={};var i=f[t]=new p.Module(t);e[t][0].call(i.exports,u,i,i.exports,s)}return f[t].exports;function u(e){var t=u.resolve(e);if(!1===t)return{};if(Array.isArray(t)){var n={__esModule:!0};return t.forEach(function(e){var t=e[0],r=e[1],o=e[2]||e[0],a=p(r);"*"===t?Object.keys(a).forEach(function(e){"default"===e||"__esModule"===e||Object.prototype.hasOwnProperty.call(n,e)||Object.defineProperty(n,e,{enumerable:!0,get:function(){return a[e]}})}):"*"===o?Object.defineProperty(n,t,{enumerable:!0,value:a}):Object.defineProperty(n,t,{enumerable:!0,get:function(){return"default"===o?a.__esModule?a.default:a:a[o]}})}),n}return p(t)}}p.isParcelRequire=!0,p.Module=function(e){this.id=e,this.bundle=p,this.require=d,this.exports={}},p.modules=e,p.cache=f,p.parent=l,p.distDir=void 0,p.publicUrl=void 0,p.devServer=void 0,p.i=u,p.register=function(t,n){e[t]=[function(e,t){t.exports=n},{}]},Object.defineProperty(p,"root",{get:function(){return s[r]}}),s[r]=p;for(var w=0;w<t.length;w++)p(t[w]);if(n){var h=p(n);"object"==typeof exports&&"u">typeof module?module.exports=h:"function"==typeof define&&define.amd&&define(function(){return h})}}({"1xnGs":[function(e,t,n,r){var o=e("@parcel/transformer-js/src/esmodule-helpers.js");o.defineInteropFlag(n),o.export(n,"default",function(){return i});var a=e("@swc/helpers/cjs/_async_to_generator.cjs"),c=e("@swc/helpers/cjs/_ts_generator.cjs");function i(e){var t=!1,n=null,r=null,o=function(e){var 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=function(t,n){var r=e.url||t.option.url,o=new window.chrome.cast.media.MediaInfo(r,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"})[r.split("?")[0].split("#")[0].split(".").pop().toLowerCase()]||"application/octet-stream"),a=new window.chrome.cast.media.LoadRequest(o);n.loadMedia(a).then(function(){var n;t.notice.show="Casting started",null==(n=e.onCastStart)||n.call(e)}).catch(function(n){var r;throw t.notice.show="Error casting media",null==(r=e.onError)||r.call(e,n),n})};return function(s){return(0,a._)(function(){return(0,c._)(this,function(l){return s.controls.add({name:"chromecast",position:"right",tooltip:"Chromecast",html:'<i class="art-icon art-icon-cast">'.concat(e.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>',"</i>"),click:function(){return(0,a._)(function(){var a,l,u,f,d;return(0,c._)(this,function(c){switch(c.label){case 0:if(t)return[3,4];c.label=1;case 1:return c.trys.push([1,3,,4]),[4,new Promise(function(a,c){var i;window.__onGCastApiAvailable=function(i){if(i){var s=window.cast.framework.CastContext.getInstance();s.setOptions({receiverApplicationId:window.chrome.cast.media.DEFAULT_MEDIA_RECEIVER_APP_ID,autoJoinPolicy:window.chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED}),s.addEventListener(window.cast.framework.CastContextEventType.SESSION_STATE_CHANGED,function(t){var a,c,i,s,l,u=window.cast.framework.SessionState;switch(r=t.sessionState,n=t.session,t.sessionState){case u.NO_SESSION:null==(a=e.onStateChange)||a.call(e,"disconnected"),o("disconnected");break;case u.SESSION_STARTING:null==(c=e.onStateChange)||c.call(e,"connecting"),o("connecting");break;case u.SESSION_STARTED:null==(i=e.onStateChange)||i.call(e,"connected"),o("connected");break;case u.SESSION_ENDING:null==(s=e.onStateChange)||s.call(e,"disconnecting"),o("disconnecting");break;case u.SESSION_RESUMED:null==(l=e.onStateChange)||l.call(e,"connected"),o("connected")}}),s.addEventListener(window.cast.framework.CastContextEventType.CAST_STATE_CHANGED,function(t){var n,r,o,a=window.cast.framework.CastState;switch(t.castState){case a.NO_DEVICES_AVALine truncated
|
||||
Reference in new issue
Block a user