ps-tcplayer
Version:
Tencent Cloud Player component with Vue2/Vue3 compatibility
28 lines (27 loc) • 38.8 kB
JavaScript
(function(d,p){typeof exports=="object"&&typeof module<"u"?module.exports=p(require("vue-demi")):typeof define=="function"&&define.amd?define(["vue-demi"],p):(d=typeof globalThis<"u"?globalThis:d||self,d.PsTcPlayer=p(d.VueDemi))})(this,function(d){"use strict";var ee=Object.defineProperty;var te=(d,p,v)=>p in d?ee(d,p,{enumerable:!0,configurable:!0,writable:!0,value:v}):d[p]=v;var T=(d,p,v)=>(te(d,typeof p!="symbol"?p+"":p,v),v);function p(i,t){let e=[...i];if(!e.length)return t&&t(),console.log("resouce loaded"),!1;let s=e.shift();if(!s)return p(e,t),!1;s.endsWith(".js")?v(s,()=>{p(e,t)}):s.endsWith(".css")?M(s,()=>{p(e,t)}):(console.warn("no suport resource:",s),p(e,t))}function v(i,t){if(document.querySelector(`script[src="${i}"]`))return console.log(i,":has youle"),t&&t(),!1;var e=document.createElement("script"),s=t||function(){};e.type="text/javascript",e.readyState?e.onreadystatechange=function(){e.readyState=="loaded"||e.readyState=="complete",e.onreadystatechange=null,s(),console.log(e.readyState)}:(e.onload=function(){s()},e.onerror=function(n){s(),console.log(n)}),e.src=i,document.querySelector("body").appendChild(e)}function M(i,t){if(document.querySelector(`link[href="${i}"]`))return console.log(i,":has youle"),t&&t(),!1;var e=document.createElement("link"),s=t||function(){};e.rel="stylesheet",e.readyState?e.onreadystatechange=function(){e.readyState=="loaded"||e.readyState=="complete",e.onreadystatechange=null,s(),console.log(e.readyState)}:(e.onload=function(){s()},e.onerror=function(n){s(),console.log(n)}),e.href=i,document.querySelector("head").appendChild(e)}const D='<div class="player-olympic-player-next"><div class="player-olympic-player-next-tip">\u4E0B\u4E00\u8282</div></div>',ie="",x="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEgAAABICAYAAABV7bNHAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAA4ZpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuNi1jMTM4IDc5LjE1OTgyNCwgMjAxNi8wOS8xNC0wMTowOTowMSAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iIHhtbG5zOnN0UmVmPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvc1R5cGUvUmVzb3VyY2VSZWYjIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtcE1NOk9yaWdpbmFsRG9jdW1lbnRJRD0ieG1wLmRpZDowOGJiODA5NC0xNDBlLTQ3NmUtOThjMS05YjkyNzUzZGUxZjUiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6NUE3MzdENzIzMDcwMTFFQkJBNDA4NUREMTk1NTZBMzEiIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6NUE3MzdENzEzMDcwMTFFQkJBNDA4NUREMTk1NTZBMzEiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENDIDIwMTcgKE1hY2ludG9zaCkiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDo5M2YyNmFjOC0zOWVjLTQ5MjctOTI1MC01OGYyODJhOThiZGEiIHN0UmVmOmRvY3VtZW50SUQ9ImFkb2JlOmRvY2lkOnBob3Rvc2hvcDowZDlmMzQwYS03OGRhLTExN2UtODljNS05ZTJkOWEyMjNlMmYiLz4gPC9yZGY6RGVzY3JpcHRpb24+IDwvcmRmOlJERj4gPC94OnhtcG1ldGE+IDw/eHBhY2tldCBlbmQ9InIiPz68KeUaAAACVklEQVR42uyaPUgcQRiG9y5yFiYgKAGRsxKJXAySIv5U2kq0EyXptFbDFQqxEESbkEIDwUIUO0OMlYiFhYJKfgoREgVRmxBUVEgEBQXj+g474Co7K+ze7ex57wsP3N3CcDzMfDvf7EZM0zQYdaJUQEEUREEUREEUREEUxFAQBVEQBVEQBVEQBTEUlLWCHoERcAzEWfIO6AYPvA4YScGZdAGoAwdgWf4xXfkMmh1+7wd9nkYUgnxQA/6a1/kGXvgc0ytxU51dr+P6XWIfQb7texX4CsZAYcCzJ+5yrUhXDXqmGLMNbIEOkJPJ9dTvoG7FT8ysD2BV1ijexRSpAAtg8o5lkPW3+VawAd6CGAU55yEYBOuggYLUKQWzYEZ+piBFXoJfYADkUZBzckGvrE8tFKROCfgk73gJClJH7JnWwNCtXToF2SJ2311gU+7KoxTknMeyr1sBTylInWqwBIopyL23e0VB7olRkDrn4AsFOec3aJR3NQqy5Uw2t+VgXtd+I6wRjWwSbOvekIUtQkgnmGOrcTMnhnWYlgiLnDDNIHEcKx7w/Qljz6MzP+VyWgxrIdS1xP5JMc/DLEfHDLoEE6AHHGXCBixIQd/lrPmRSb1NEEvsELSD2kyTk25BF2AYlIFxubzSvXxDJ0jVG4nCWwneyIIcRNy2CHu6BCVll21vKsUT1HrDejgYdEM7rbg26nXQVLxA9QQ0GdYLVFPgVGPJEG+YvQOv5ed9wzr8fw/+6xJ0r8OXOCmIgiiIgiiIgiiIghgKoiAKoiAKoiAKoiDGlisBBgBcQ0BsCEYJ1AAAAABJRU5ErkJggg==";function f(i){let t=document.createElement("div");return t.innerHTML=i.trim(),t.childNodes[0]}function S(i,t){const e=t.parentNode;e.lastChild===t?e.appendChild(i):e.insertBefore(i,t.nextSibling)}class R{constructor(t,e){this.player=t,this.clickHandle=e,this.$html=f(D)}createEl(t){if(this.clickHandle){this.$html.onclick=()=>{console.log("this.clickHandle",this.clickHandle),typeof this.clickHandle=="function"?this.clickHandle():typeof this.clickHandle=="string"&&(window.location.href=this.clickHandle)},this.$html.style.backgroundImage=`url(${x})`;const e=t.querySelector(".vjs-play-control");S(this.$html,e)}}dispose(){this.$html.parentNode.removeChild(this.$html)}}const P='<div class="player-olympic-player-prev"><div class="player-olympic-player-prev-tip">\u4E0A\u4E00\u8282</div></div>',se="",H="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEgAAABICAYAAABV7bNHAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAA4RpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuNi1jMTM4IDc5LjE1OTgyNCwgMjAxNi8wOS8xNC0wMTowOTowMSAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wTU09Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9tbS8iIHhtbG5zOnN0UmVmPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvc1R5cGUvUmVzb3VyY2VSZWYjIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtcE1NOk9yaWdpbmFsRG9jdW1lbnRJRD0ieG1wLmRpZDplNmVjNDgwYi02N2JjLWMwNDYtYmI4NS01MTM1YjIyYzlkZGMiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6NUE3MzdENkUzMDcwMTFFQkJBNDA4NUREMTk1NTZBMzEiIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6NUE3MzdENkQzMDcwMTFFQkJBNDA4NUREMTk1NTZBMzEiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENDIDIwMTcgKFdpbmRvd3MpIj4gPHhtcE1NOkRlcml2ZWRGcm9tIHN0UmVmOmluc3RhbmNlSUQ9InhtcC5paWQ6YmZiYTcwMTAtN2VkYi00MjQ4LTllNDgtZTY1YzEzNWE0ZTJjIiBzdFJlZjpkb2N1bWVudElEPSJhZG9iZTpkb2NpZDpwaG90b3Nob3A6NTcyMDAwOGItNzhkYS0xMTdlLTg5YzUtOWUyZDlhMjIzZTJmIi8+IDwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY+IDwveDp4bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8+87YrpwAAAk9JREFUeNrsmj9IG1EAhy/a6qAUhyKCqEtFigq2g7SaQVdBh4JU2qXorDiEaksRHErBqf4Bh9COugiCQRwcDLiEughSsBpBRCSIolgRlTTp73FvCOWehrty7134ffAtAR/nl3vv7l0ulM1mLaImxEAMxEAMxEAMxEAMxECEgRiIgRiIgRiIgRiIMFDeFHn8+2L4Hu5BUToFZ+EjnkE243DM4fNF+Ern/wXDsBLG4anrkUQgDx5l1dR5HNutrTCRcxxnsM3teF4P5i7CPod5DL/BPw7HsuF23KICWCYewEG4C/sV6+ozL4MHmQ44BZvzuJhouYrpogbOwbU84ng+PYNECYzAD7Dcr/kbFLrgJHwSpBtFPxBBYnDZ7zimn0FiCo3KKVWq8xJpIq/hBKw14R7CJBrhjLx8F8Rm9X9RAb/CTZPimHAGiS/oHfwiN5ZG3qbroglG4QvT9zE6qIbrcmoZja416G0Q4ugM9DAot++6Ai3AGwZS8wt2wwMGUrMKn8LP8JqBnLmCnyz7mU6MgdQkYY9lP9JIMpCaFbkf+wgvGciZW7n1EOvTPAOpOYRvYCfcYiA1cfgcDsFzBnImDadhPfwOMwzkzAkcgC9hgoHU/IDtMtYxAzmTkdOtwbJ/DkqbGCh1z1XID8TCPQxb5ILuxI6uQFHF5+L9oH2fz6if8pag759NsHhqMOJ2UK8vUImXAiLyG6yCvy37N3Px1tmFxulXBnst+zn3EtzWFajgYSAGYiAGYiAGYiAGYiDCQAzEQAzEQAzEQAxEcvgrwADvsYR/Evmv3QAAAABJRU5ErkJggg==";class N{constructor(t,e){this.player=t,this.clickHandle=e,this.$html=f(P)}createEl(t){if(this.clickHandle){this.$html.onclick=()=>{typeof this.clickHandle=="function"?this.clickHandle():typeof this.clickHandle=="string"&&(window.location.href=this.clickHandle)},this.$html.style.backgroundImage=`url(${H})`;const e=t.querySelector(".vjs-play-control");S(this.$html,e)}}dispose(){this.$html.parentNode.removeChild(this.$html)}}const _='<div class="memory-play-wrap"></div>',ne="";class B{constructor(t,e=!1,s,n,r){this.html=f(_),this.player=t,this.autoPlay=e,this.getTime=s||this._getTime,this.saveTimeFunction=n||this._saveTime,this.hasMemoryDisplay=!1,this.htime=r||0,this.memoryKey="tcplayer_memory_"}createEl(t){t.appendChild(this.html)}ready(){try{const l=this.player;let a=this,u=l.options_||{},c="";u.fileID?c=u.fileID:u.src&&(c=u.src.replace(/\?.*$/,"")),this.memoryKey="tcplayer_memory_"+c;let y=0;this.htime>0?y=this.htime:y=this.getTime(this.memoryKey)?parseInt(this.getTime(this.memoryKey)):0,this.hasMemoryDisplay=!1;var t,e,s,n;if(e=this.getVideoTime(y),t=this.getVideoTime(this.htime),!this.hasMemoryDisplay&&y>0){this.hasMemoryDisplay=!0;let C=0;try{C=l.duration()||0}catch(m){console.error("\u83B7\u53D6\u89C6\u9891\u65F6\u957F\u5931\u8D25:",m)}if(y<=parseInt(C)-2){var r="";n=0,s=e,this.autoPlay?(r=`<div class="memory-play"><span>\u60A8\u4E0A\u6B21\u5B66\u4E60\u5230${s}\u5DF2\u81EA\u52A8\u4E3A\u60A8\u7EED\u64AD</span><span class="play-jump">\u4ECE\u5934\u64AD\u653E</span><i class="iconfont icon-close"></i></div>`,l.currentTime(y)):r=`<div class="memory-play"><span>\u60A8\u4E0A\u6B21\u5B66\u4E60\u5230${s}</span><span class="play-jump">\u7EE7\u7EED\u64AD\u653E</span><i class="iconfont icon-close"></i></div>`,l.paused()&&this.autoPlay,this.html.innerHTML=r;let m=setTimeout(()=>{this.html.innerHTML=""},5e3);var o=this.html.querySelector(".icon-close");o&&(o.onclick=()=>{this.html.innerHTML="",clearTimeout(m)});var h=this.html.querySelector(".play-jump");h&&(h.onclick=()=>{if(this.autoPlay?l.currentTime(0):l.currentTime(y),l.paused()&&this.autoPlay)try{l.play().catch(w=>{console.warn("\u70B9\u51FB\u540E\u64AD\u653E\u88AB\u963B\u6B62\uFF0C\u8FD9\u79CD\u60C5\u51B5\u5F88\u5C11\u89C1:",w)})}catch(w){console.warn("\u64AD\u653E\u5C1D\u8BD5\u5931\u8D25:",w)}this.html.innerHTML="",clearTimeout(m)})}}setTimeout(()=>{!this.hasMemoryDisplay&&y>0&&this.processMemoryPlayPrompt(y)},500),this.setupTimeSaving()}catch(l){console.error(l)}}error(){this.setMemory()}dispose(){this.setMemory(),this.visibilityHandler&&document.removeEventListener("visibilitychange",this.visibilityHandler),this.unloadHandler&&window.removeEventListener("beforeunload",this.unloadHandler),this.progressInterval&&clearInterval(this.progressInterval)}processMemoryPlayPrompt(t){const e=this.player;this.hasMemoryDisplay=!0;let s=0;try{s=e.duration()||0}catch(n){console.error("\u83B7\u53D6\u89C6\u9891\u65F6\u957F\u5931\u8D25:",n)}if(t<=parseInt(s)-2){const n=this.getVideoTime(t);let r="";this.autoPlay?(r=`<div class="memory-play"><span>\u60A8\u4E0A\u6B21\u5B66\u4E60\u5230${n}\u5DF2\u81EA\u52A8\u4E3A\u60A8\u7EED\u64AD</span><span class="play-jump">\u4ECE\u5934\u64AD\u653E</span><i class="iconfont icon-close"></i></div>`,e.currentTime(t)):r=`<div class="memory-play"><span>\u60A8\u4E0A\u6B21\u5B66\u4E60\u5230${n}</span><span class="play-jump">\u7EE7\u7EED\u64AD\u653E</span><i class="iconfont icon-close"></i></div>`,this.html.innerHTML=r;let o=setTimeout(()=>{this.html.innerHTML=""},5e3);const h=this.html.querySelector(".icon-close");h&&(h.onclick=()=>{this.html.innerHTML="",clearTimeout(o)});const l=this.html.querySelector(".play-jump");l&&(l.onclick=()=>{if(this.autoPlay?e.currentTime(0):e.currentTime(t),e.paused())try{e.play().catch(a=>{console.warn("\u70B9\u51FB\u540E\u64AD\u653E\u88AB\u963B\u6B62:",a)})}catch(a){console.warn("\u64AD\u653E\u5C1D\u8BD5\u5931\u8D25:",a)}this.html.innerHTML="",clearTimeout(o)})}}setupTimeSaving(){const t=this.player;let e=this;document.removeEventListener("visibilitychange",this.visibilityHandler),this.visibilityHandler=function(){document.visibilityState==="hidden"&&t.currentTime()>0&&e.saveTimeFunction(e.memoryKey,t.currentTime())},document.addEventListener("visibilitychange",this.visibilityHandler),window.removeEventListener("beforeunload",this.unloadHandler),this.unloadHandler=function(){t.currentTime()>0&&e.saveTimeFunction(e.memoryKey,t.currentTime())},window.addEventListener("beforeunload",this.unloadHandler),this.progressInterval=setInterval(()=>{!t.paused()&&t.currentTime()>0&&e.saveTimeFunction(e.memoryKey,t.currentTime())},3e4)}setMemory(){const t=this.player;try{if(!t||typeof t.currentTime!="function")return;const e=t.currentTime();e>0&&this.saveTimeFunction(this.memoryKey,e)}catch(e){console.error("\u4FDD\u5B58\u8BB0\u5FC6\u65F6\u95F4\u5931\u8D25:",e)}}getVideoTime(t){let e=Math.round(t),s=Math.floor(e/3600),n=Math.floor((e-s*3600)/60),r=e-s*3600-n*60;return n<10&&(n="0"+n),r<10&&(r="0"+r),s===0?n+":"+r:s+":"+n+":"+r}_getTime(t){return localStorage.getItem(t)}_saveTime(t,e){localStorage.setItem(t,e)}}const G=`
<div class="quality-components">
<div class="current-quality-cto" data-ref=""></div>
<ul class="quality-list">
</ul>
</div>
`,Y=`
<div class="quality-modal">
<span class="switchimg"></span> <span class="current-quality-tag"></span> , <span class="wait"></span>
</div>
`,re="";class L{constructor(t,e,s,n){this.player=t,this.html=f(G),this.modalHtml=f(Y),this.hasCreated=!1,this.definition=s,this.getQuality=e,this.desc=n,this.html.style.display="none"}createEl(t){const e=this.player;let s=!1;try{typeof e.lang=="function"?s=e.lang()==="en-us":typeof e.lang=="string"?s=e.lang==="en-us":e.options_&&e.options_.language&&(s=e.options_.language==="en-us")}catch{console.warn("\u65E0\u6CD5\u83B7\u53D6\u64AD\u653E\u5668\u8BED\u8A00\u8BBE\u7F6E\uFF0C\u4F7F\u7528\u9ED8\u8BA4\u4E2D\u6587")}this.isEn=s,this.html.querySelector(".current-quality-cto").innerText=this.isEn?"Resolution":this.desc||"\u6E05\u6670\u5EA6",this.modalHtml.querySelector(".switchimg").innerText=this.isEn?"Switching to you for":"\u6B63\u5728\u4E3A\u60A8\u5207\u6362\u5230",this.modalHtml.querySelector(".wait").innerText=this.isEn?"Please wait...":"\u8BF7\u7A0D\u540E...";let n=t.querySelector(".vcp-controls-panel");n?n.appendChild(this.html):(console.warn("\u627E\u4E0D\u5230\u64AD\u653E\u5668\u63A7\u5236\u680F\uFF0C\u5C1D\u8BD5\u6DFB\u52A0\u5230\u6839\u5143\u7D20"),t.appendChild(this.html)),t.appendChild(this.modalHtml)}setCurrentQuality(t,e){this.html.style.display="block";let s=this.html.querySelector(".current-quality-cto");s.innerText=t,s.dataset.def=e,this.definition=e;let n=this.html.querySelector(".quality-list"),r=n.querySelector(".current");r&&(r.className="");let o=n.querySelector(`li[data-def="${e}"]`);o&&(o.className="current")}filterDefinitionList(t){return t.filter(e=>e.definition!=="SD")}created(){const t=this.player;try{let n=[];if(t.getVideoQualityList&&typeof t.getVideoQualityList=="function")n=t.getVideoQualityList();else if(t.qualities&&typeof t.qualities=="function")n=t.qualities();else if(t.tech_&&t.tech_.hls&&t.tech_.hls.representations){const c=t.tech_.hls.representations();n=Array.from(c).map((y,C)=>({definition:y.height+"p",name:y.height+"p",url:y.id}))}else console.warn("\u65E0\u6CD5\u83B7\u53D6\u6E05\u6670\u5EA6\u5217\u8868\uFF0C\u4F7F\u7528\u9ED8\u8BA4\u503C"),n=[{definition:"HD",name:"\u8D85\u6E05",url:""},{definition:"SD",name:"\u6807\u6E05",url:""}];this._urls=n.map(c=>({definition:c.definition||c.id||"HD",desc:c.name||c.label||"\u9AD8\u6E05",Url:c.url||""})),(!this._urls||this._urls.length===0)&&(this._urls=[{definition:"HD",desc:"\u8D85\u6E05",Url:""},{definition:"SD",desc:"\u6807\u6E05",Url:""}]);for(var e=0;e<this._urls.length;e++)this._urls[e].definition==="AUTO"&&(this._urls[e].desc="\u81EA\u52A8"),this._urls[e].desc||(this._urls[e].desc="");let r=this.html.querySelector(".current-quality-cto"),o=this.html.querySelector(".quality-list");if(!r||!o){console.error("\u6E05\u6670\u5EA6\u7EC4\u4EF6HTML\u5143\u7D20\u672A\u627E\u5230");return}let l=this.filterDefinitionList(this._urls).map(c=>`<li data-def="${c.definition}">${c.desc}</li>`);const a=this.html.querySelector(".quality-list");if(a&&(a.innerHTML=l.join("")),this.hasCreated==!1){if(!this.definition&&this._urls.length>0){let c=o.querySelector(`li[data-def="${this._urls[0].definition}"]`);c&&(c.className="current",r.innerText=this._urls[0].desc)}else for(var e=0;e<this._urls.length;e++)if(this.definition==this._urls[e].definition){var s=o.querySelector(`li[data-def="${this.definition}"]`);s&&(s.className="current",r.innerText=this._urls[e].desc);break}}this.hasCreated=!0;let u=null;r.onclick=()=>{o.style.display="block"},r.onmouseleave=()=>{u=setTimeout(()=>{o.style.display="none"},100)},o.onmouseenter=()=>{clearTimeout(u)},o.onmouseleave=()=>{o.style.display="none"},o.onclick=({target:c})=>{let y=c.dataset.def,C=c.innerText;if(y&&c.className!=="current"){let m=this._urls.find(g=>g.definition===y);if(!m)return;let w=0;try{w=t.currentTime()}catch(g){console.warn("\u65E0\u6CD5\u83B7\u53D6\u5F53\u524D\u64AD\u653E\u65F6\u95F4",g)}try{if(t.switchQuality&&typeof t.switchQuality=="function")t.switchQuality(y);else if(t.tech_&&t.tech_.hls&&t.tech_.hls.selectPlaylist){const g=t.tech_.hls.representations(),I=Array.from(g).find(K=>K.height+"p"===y);I&&I.enabled(!0)}}catch(g){console.warn("\u5207\u6362\u6E05\u6670\u5EA6\u5931\u8D25",g)}this.setCurrentQuality(m.desc,m.definition),this.modalHtml.style.display="block";const $=this.modalHtml.querySelector("span.current-quality-tag");$&&($.innerText=m.desc),setTimeout(()=>{try{t.currentTime(w)}catch(g){console.warn("\u65E0\u6CD5\u8BBE\u7F6E\u64AD\u653E\u65F6\u95F4",g)}},500)}console.log(y,"getQuality-definition"),console.log(C,"getQuality-desc");try{localStorage.setItem("cto_video_definition",y),localStorage.setItem("cto_video_desc",C)}catch(m){console.warn("\u65E0\u6CD5\u4FDD\u5B58\u6E05\u6670\u5EA6\u8BBE\u7F6E\u5230localStorage",m)}u=setTimeout(()=>{o.style.display="none"},100)}}catch(n){console.error("QualityComponent\u521B\u5EFA\u8FC7\u7A0B\u51FA\u9519:",n)}}ready(){const t=this.player;try{let e=null;if(t.getVideoQuality&&typeof t.getVideoQuality=="function")try{e=t.getVideoQuality(),console.log(e,"Quality")}catch(s){console.warn("\u83B7\u53D6\u89C6\u9891\u6E05\u6670\u5EA6\u5931\u8D25",s)}this.modalHtml&&(this.modalHtml.style.display="none");try{let s=document.querySelector(".vcp-quality");s&&(s.style.display="none")}catch(s){console.warn("\u65E0\u6CD5\u9690\u85CF\u539F\u59CB\u6E05\u6670\u5EA6\u6309\u94AE",s)}}catch(e){console.error("QualityComponent ready\u8FC7\u7A0B\u51FA\u9519:",e)}}}const U=`
<div class="rate-components">
<div class="current-rate">1.0x</div>
<ul class="rate-list">
<li data-rate="2.0">2.0x</li>
<li data-rate="1.75">1.75x</li>
<li data-rate="1.5">1.5x</li>
<li data-rate="1.25">1.25x</li>
<li data-rate="1.0" class="current">1.0x</li>
<li data-rate="0.5">0.5x</li>
</ul>
</div>
`,oe="";class Q{constructor(t){this.html=f(U),this.player=t,this.hasCreated=!1,this.rate=this.getRate()}createEl(t){try{if(!t){console.warn("RateComponent: DOM\u5143\u7D20\u4E0D\u5B58\u5728");return}let e=t.querySelector(".vcp-controls-panel");if(!e){console.warn("RateComponent: \u65E0\u6CD5\u627E\u5230\u63A7\u5236\u680F\u5143\u7D20\uFF0C\u5C1D\u8BD5\u6DFB\u52A0\u5230\u6839\u5143\u7D20"),t.appendChild(this.html);return}e.appendChild(this.html)}catch(e){console.error("RateComponent\u521B\u5EFADOM\u5143\u7D20\u5931\u8D25:",e)}}created(){if(this.hasCreated==!1){if(this.rate){this.player.playbackRate(parseFloat(this.rate));let e=this.html.querySelector('li[class="current"]');e&&(e.className="");let s=this.html.querySelector(`li[data-rate="${this.rate}"]`);s&&(s.className="current")}else this.rate="1.0";let t=this.html.querySelector(".current-rate");t.innerText=this.rate+"x"}this.hasCreated=!0}ready(){let t=this.html.querySelector(".current-rate"),e=this.html.querySelector(".rate-list"),s=null,n=document.querySelector(".vcp-rate");n&&(n.style.display="none"),t.onclick=()=>{e.style.display="block"},t.onmouseleave=()=>{s=setTimeout(()=>{e.style.display="none"},100)},e.onmouseenter=()=>{clearTimeout(s)},e.onmouseleave=()=>{e.style.display="none"},e.onclick=({target:r})=>{let o=r.dataset.rate;if(o){if(this.player.playbackRate(parseFloat(o)),r.className!=="current"){let h=e.querySelector(".current");h&&(h.className=""),r.className="current"}e.style.display="none",t.innerText=o+"x",this.setRate(o)}}}setRate(t){localStorage.setItem("cto_video_Rate",t)}getRate(){return localStorage.getItem("cto_video_Rate")}}const le="";class O{constructor(t,e,s,n="random"){this.text=e,this.style=s||{fontSize:"14px",color:"#fff"},this.html=f('<div class="bullet-screen paused"></div>'),this.bulletPosition=n,this.mintime=90,this.maxtime=180,this.animationtime=10,this.time=0,this.stoptime=0,this.start=new Date,this.player=t}createEl(t){this.html.innerText=this.text,t.appendChild(this.html)}ready(t){const e=this.player;e.autoplay()===!1&&(this.html.style.animationPlayState="paused"),Object.keys(this.style).forEach(o=>this.html.style[o]=this.style[o]);var s=this.html.offsetHeight,n=parseInt(e.height()),r=n-s;if(this.bulletPosition==="bottom")this.html.style.bottom=0;else{let o=this.bulletPosition==="top"?0:this.randomTop(r);this.html.style.top=o}this.bulletPosition==="random"&&this.html.addEventListener("animationiteration",()=>{this.html.style.top=this.randomTop(r)}),this.html.style.webkitAnimationDuration=this.animationtime+"s",this.start=new Date}playing(t){console.log("bulletplayering"),this.html.style.animationPlayState="running",this.start=new Date}timeupdate(t){const e=this.player;var s=Math.random();this.maxtime-this.mintime>0?s=this.mintime+(this.maxtime-this.mintime)*s:s=0;let n=e.el(),r=n.querySelector(".bullet-screen");if(this.time=new Date-this.start+this.stoptime,!r)this.time-this.animationtime*1e3-s*1e3>0&&(n.appendChild(this.html),this.start=new Date,this.stoptime=0);else if(this.time-this.animationtime*1e3>0)r.remove(),this.stoptime=0;else{r.className!=="bullet-screen"&&(r.className="bullet-screen");let o=getComputedStyle(r),h=o.getPropertyValue("display"),l=o.getPropertyValue("opacity"),a=o.getPropertyValue("visibility"),u=this.text,c=r.innerText;h==="none"&&r.style.setProperty("display","block"),l!=="1"&&r.style.setProperty("opacity","1"),a==="hidden"&&r.style.setProperty("visibility","visible"),u!=c&&(r.innerText=u)}}pause(t){console.log("pause"),this.html.style.animationPlayState="paused"}randomTop(t){return Math.floor(Math.random()*t)+"px"}}const Z={CountdownHtml:'<div class="countdown-wrap"><div class="countdown"></div></div>',RateHtml:'<div class="player-rate-wrap"><div class="player-rate-tips">\u8FD9\u8282\u8BFE\u7A0B\u60A8\u662F\u5426\u6EE1\u610F\uFF1F</div><div class="player-rate-box"><div class="player-star-wrap"><i class="player-icon player-star" data-id="1"></i><i class="player-icon player-star" data-id="2"></i><i class="player-icon player-star" data-id="3"></i><i class="player-icon player-star" data-id="4"></i><i class="player-icon player-star" data-id="5"></i></div><div class="player-rate-txt">\u8BC4\u5206</div></div></div>'},ae="";class z{constructor(t,e=!0,s,n,r){this.html=f(Z.CountdownHtml),this.player=t,this.open=e,this.time=s||15,this.type=n,this.isClicked=!1,this.starOpen=r,this.player.on("timeupdate",()=>this.timeupdate())}createEl(t){this.open&&t.appendChild(this.html)}timeupdate(){const t=this.player;if(this.type=="star"){var e=t.duration()-t.currentTime();e<=this.time&&this.starOpen()}else if(this.open){var s=this.html.querySelector(".countdown"),e=t.duration()-t.currentTime();if(e<=this.time){e=e-e%1+1;var n=`<div class="countdown-txt">
<span class="time">${e}s</span>\u540E\u4E3A\u60A8\u64AD\u653E\u4E0B\u4E00\u8282
</div>`;s.innerHTML=n}else s.innerHTML=""}}getVideoTime(t){let e=Math.round(t),s=Math.floor(e/3600),n=Math.floor((e-s*3600)/60),r=e-s*3600-n*60;return n<10&&(n="0"+n),r<10&&(r="0"+r),s===0?n+":"+r:s+":"+n+":"+r}}const F=`
<div class="prism-snapshot-btn"></div>
`,ce="";class j{constructor(t){this.player=t,this.html=f(F)}createEl(t){const e=t.querySelector(".vjs-control-bar"),s=e.querySelector(".tcp-video-quality-switcher");e.insertBefore(this.html,s.nextSibling)}ready(){this.html.addEventListener("click",()=>{this.captureSnapshot()})}captureSnapshot(){const t=this.player,e=t.tech_.el_;if(!e){console.error("\u89C6\u9891\u5143\u7D20\u4E0D\u5B58\u5728");return}const s=document.createElement("canvas");s.width=e.videoWidth,s.height=e.videoHeight,s.getContext("2d").drawImage(e,0,0,s.width,s.height);try{const r=s.toDataURL("image/png"),o=document.createElement("a");o.href=r;const h=new Date().toISOString().replace(/[:.]/g,"-"),a=`${t.el_.getAttribute("title")||"video"}_${h}.png`;o.download=a,document.body.appendChild(o),o.click(),document.body.removeChild(o)}catch(r){console.error("\u622A\u56FE\u5931\u8D25:",r)}}}const k={PlayerNextComponent:R,PlayPrevComponent:N,MemoryPlayComponent:B,QualityComponent:L,RateComponent:Q,BulletScreenComponent:O,CountdownComponent:z,SnapshotComponent:j};window.TcPlayerComponent=k;function V(i){!i||(i.lang||(i.lang=function(t){return{Play:"\u64AD\u653E",Pause:"\u6682\u505C",Mute:"\u9759\u97F3",Unmute:"\u53D6\u6D88\u9759\u97F3",Fullscreen:"\u5168\u5C4F","Exit Fullscreen":"\u9000\u51FA\u5168\u5C4F",Settings:"\u8BBE\u7F6E",Speed:"\u901F\u5EA6",Normal:"\u6B63\u5E38",Quality:"\u8D28\u91CF",Auto:"\u81EA\u52A8",HD:"\u9AD8\u6E05",SD:"\u6807\u6E05"}[t]||t}),i.options_||(i.options_=i.options_||{}),i.options_&&!i.options_.languages&&(i.options_.languages={"zh-CN":{Play:"\u64AD\u653E",Pause:"\u6682\u505C",Mute:"\u9759\u97F3",Unmute:"\u53D6\u6D88\u9759\u97F3",Fullscreen:"\u5168\u5C4F","Exit Fullscreen":"\u9000\u51FA\u5168\u5C4F",Settings:"\u8BBE\u7F6E",Speed:"\u901F\u5EA6",Normal:"\u6B63\u5E38",Quality:"\u8D28\u91CF",Auto:"\u81EA\u52A8",HD:"\u9AD8\u6E05",SD:"\u6807\u6E05"}},i.options_.language="zh-CN"))}function q(i,t){if(!i)return[];const e=[];try{if(!t||!Array.isArray(t))return e;t.forEach(s=>{try{if(s.type&&typeof s.type=="function"){if(!i||!i.el_){console.warn("\u64AD\u653E\u5668\u5B9E\u4F8B\u4E0D\u5B8C\u6574\uFF0C\u8DF3\u8FC7\u7EC4\u4EF6\u6CE8\u518C",s.name);return}let n;try{n=new s.type(i,...s.args||[])}catch(r){console.error(`\u7EC4\u4EF6 ${s.name} \u521D\u59CB\u5316\u5931\u8D25:`,r);return}if(s.name){if(i._components||(i._components={}),i._components[s.name]=n,e.push(n),i.getComponent||(i.getComponent=function(r){return this._components&&this._components[r]}),n.createEl&&typeof n.createEl=="function")try{i.el_&&i.el_.nodeType===1?n.createEl(i.el_):console.warn(`\u7EC4\u4EF6 ${s.name} \u8DF3\u8FC7DOM\u521B\u5EFA\uFF0C\u64AD\u653E\u5668\u5143\u7D20\u4E0D\u5B58\u5728`)}catch(r){console.error(`\u7EC4\u4EF6 ${s.name} \u521B\u5EFADOM\u5143\u7D20\u5931\u8D25:`,r),console.log("\u7EC4\u4EF6:",n),console.log("\u9519\u8BEF\u8BE6\u60C5:",r)}if(n.created&&typeof n.created=="function")try{n.created()}catch(r){console.error(`\u7EC4\u4EF6 ${s.name} created\u65B9\u6CD5\u6267\u884C\u5931\u8D25:`,r)}}}}catch(n){console.error("\u5904\u7406\u63D2\u4EF6\u65F6\u53D1\u751F\u9519\u8BEF:",n)}})}catch(s){console.error("\u6CE8\u518C\u7EC4\u4EF6\u9519\u8BEF:",s)}return e}function J(i){if(!(!i||!i._components))try{Object.values(i._components).forEach(t=>{try{t.ready&&typeof t.ready=="function"&&t.ready()}catch(e){console.error("\u7EC4\u4EF6ready\u65B9\u6CD5\u6267\u884C\u5931\u8D25:",e)}})}catch(t){console.error("\u521D\u59CB\u5316\u7EC4\u4EF6ready\u72B6\u6001\u5931\u8D25:",t)}}function W(i){if(!(!i||!i._components))try{Object.values(i._components).forEach(t=>{try{t.destroy&&typeof t.destroy=="function"&&t.destroy()}catch(e){console.error("\u7EC4\u4EF6destroy\u65B9\u6CD5\u6267\u884C\u5931\u8D25:",e)}}),i._components={}}catch(t){console.error("\u9500\u6BC1\u7EC4\u4EF6\u5931\u8D25:",t)}}const b={addPlayerCompatLayer:V,registerComponents:q,initComponentsReadyState:J,destroyComponents:W},he="";window._pursuer=window._pursuer||{};const A=window._pursuer,X={name:"PsTcPlayer",props:{config:{default(){return{}}}},data(){return{id:"",duration:0,currentTime:0,hearttime:2e4,timers:[],_readyCalled:!1}},render(){return d.h("div",{class:"ps-player",style:{width:"100%",height:"100%",position:"relative"}},[d.h("video",{class:"ps-player-container",style:{overflow:"hidden",position:"relative",width:"100%",height:"100%"},attrs:{preload:"auto",playsinline:"","webkit-playsinline":"",tabindex:"1",id:this.id},preload:"auto",playsinline:"","webkit-playsinline":"",tabindex:"1",id:this.id,ref:"playerBox"})])},watch:{config:{handler(i,t){if(!t||Object.keys(t).length===0){console.log("\u521D\u59CB\u914D\u7F6E\uFF0C\u901A\u8FC7mounted\u94A9\u5B50\u521D\u59CB\u5316");return}this._source_loded&&JSON.stringify(i)!==JSON.stringify(t)&&(console.log("\u914D\u7F6E\u53D8\u66F4\uFF0C\u91CD\u65B0\u521D\u59CB\u5316\u64AD\u653E\u5668"),this.$nextTick(()=>{this.init()}))},deep:!0}},mounted(){if(!window)return!1;this.id=this.getCfPlayerId();let i=[];const t="//web.sdk.qcloud.com/player/tcplayer/release/v4.5.2/tcplayer.v4.5.2.min.js",e="//web.sdk.qcloud.com/player/tcplayer/release/v4.5.2/tcplayer.min.css",s="//web.sdk.qcloud.com/player/tcplayer/release/v4.5.2/libs/hls.min.0.13.2m.js";window.TCPlayer||(i=[e,s,t]),p(i,()=>{this._source_loded=!0,this.$nextTick(()=>{this.init()})}),this.$playerBox=document,this.$playerBox.addEventListener("keydown",this.onkeydown,!0),this.$playerBox.addEventListener("keyup",this.onkeyup,!0)},beforeDestroy(){this.destroy()},beforeUnmount(){this.destroy()},methods:{getCfPlayerId(){A.playerCount=A.playerCount?A.playerCount+1:1;const i=this.config&&this.config.id||`player-container-id-${A.playerCount}`;return console.log("\u751F\u6210\u64AD\u653E\u5668ID:",i),i},init(){console.log("\u5F00\u59CB\u521D\u59CB\u5316\u64AD\u653E\u5668\uFF0C\u67E5\u627EDOM\u5143\u7D20:",`#${this.id}`);const i=document.querySelector(`#${this.id}`);if(console.log("\u627E\u5230\u7684DOM\u5143\u7D20:",i),!i){console.error(`#${this.id} dom is not found`);return}const t={width:"686px",height:"450px",reportable:!0,plugins:{ContinuePlay:{auto:!0},ProgressMarker:!1,ContextMenu:{levelSwitch:{open:!0,switchingText:"\u6B63\u5728\u4E3A\u60A8\u5207\u6362\u5230",switchedText:"",switchErrorText:""}}}};this.initPlayer({...this.config,...t,...this.config.tconfig||{}})},setupPlugins(){var e;const i=this,t=[];try{const s=i.config.tconfig||{},n=s.plugins||{},r=i.config.plugins||s.customPlugins||{},o={PlayerNextComponent:{enabled:i.config.onnext||i.config.showNext||!1,args:[i.onnext]},PlayPrevComponent:{enabled:i.config.onpre||i.config.showPre||!1,args:[i.onpre]},MemoryPlayComponent:{enabled:!0,args:[((e=n.ContinuePlay)==null?void 0:e.auto)===!0,null,null,i.config.htime||0]},QualityComponent:{enabled:!0,args:[null,"HD","\u9AD8\u6E05"]},RateComponent:{enabled:!0,args:[]},SnapshotComponent:{enabled:!0,args:[]},BulletScreenComponent:{enabled:i.config.bulletScreen!==!1,args:[i.config.bulletContent||"\u5B66\u4E60\u6210\u5C31\u68A6\u60F3",i.config.bulletStyle||{fontSize:"16px",color:"#fff"},"random"]},CountdownComponent:{enabled:i.config.onnext||i.config.showNext||!1,args:[i.config.onnext||i.config.showNext?!0:"",!1,i.config.star,i.config.openStar]}},h={...o};Object.keys(r).forEach(l=>{var u;const a=r[l];typeof a=="boolean"?h[l]?h[l].enabled=a:h[l]={enabled:a,args:[]}:typeof a=="object"&&a!==null&&(h[l]={enabled:a.enabled!==!1,args:a.args||((u=h[l])==null?void 0:u.args)||[],config:a.config||a})}),Object.keys(h).forEach(l=>{const a=h[l];if(a.enabled)try{const u={name:l,args:a.args||[]};k[l]&&(u.type=k[l]),a.config&&(u.config=a.config),t.push(u)}catch(u){console.error(`\u6DFB\u52A0\u63D2\u4EF6 ${l} \u5931\u8D25:`,u)}}),Object.keys(r).forEach(l=>{if(!o[l]){const a=r[l];a&&a.enabled!==!1&&t.push({name:l,config:a,args:a.args||[]})}})}catch(s){console.error("\u8BBE\u7F6E\u63D2\u4EF6\u65F6\u51FA\u9519:",s)}return t},initPlayer(i){if(console.log("\u521D\u59CB\u5316\u64AD\u653E\u5668\u914D\u7F6E:",i),this.$player&&(console.log("\u64AD\u653E\u5668\u5B9E\u4F8B\u5DF2\u5B58\u5728\uFF0C\u9500\u6BC1\u65E7\u5B9E\u4F8B"),this.destroy()),!window.TCPlayer)return console.warn("TCPlayer \u672A\u52A0\u8F7D\uFF0C\u65E0\u6CD5\u521D\u59CB\u5316\u64AD\u653E\u5668"),!1;console.log("\u521B\u5EFA TCPlayer \u5B9E\u4F8B\uFF0C\u914D\u7F6E:",i),this.hearttime=this.config.hearttime||this.hearttime,this.runs(i)},runs(i){if(this.$player=new TCPlayer(this.id,i),console.log("\u521B\u5EFA\u64AD\u653E\u5668\u5B9E\u4F8B\uFF0C\u914D\u7F6E:",i),this.$player){b.addPlayerCompatLayer(this.$player);let t=[];try{t=this.setupPlugins()||[]}catch(e){console.error("\u8BBE\u7F6E\u63D2\u4EF6\u65F6\u51FA\u9519:",e)}this.$player.on("ready",()=>{setTimeout(()=>{try{b.registerComponents(this.$player,t),this.onready()}catch(e){console.error("\u6CE8\u518C\u7EC4\u4EF6\u8FC7\u7A0B\u4E2D\u53D1\u751F\u9519\u8BEF:",e)}},500)}),this.$player.on("error",this.onerror),this.$player.on("timeupdate",this.ontimeupdate),this.$player.on("pause",this.onpause),this.$player.on("play",this.onplay),this.$player.on("ended",this.onended),this.$player.on("waiting",this.onwaiting),this.$player.on("snapshoted",this.onsnapshoted),this.$player.on("sourceloaded",this.onsourceloaded)}else{console.error("TCPlayer\u5B9E\u4F8B\u521B\u5EFA\u5931\u8D25");return}this.$player.getDuration=this.$player.duration,this.$player.getCurrentTime=this.$player.currentTime,this.$player._el=this.$player.el_,this.$player.seek=this.$player.currentTime,this.$player.getStatus=this.$player.getStatus||function(){return this.$player.paused()?"pause":"playing"}.bind(this),this.$player.destroy=this.$player.dispose,this.$player._originalPlaybackRate=this.$player.playbackRate,this.$player.getVolume=this.$player.volume,this.$player.setVolume=this.$player.volume},onready(){if(!this._readyCalled){this._readyCalled=!0,this.onheart(!0),this.$emit("onready",this.$player),this.config.onready&&this.config.onready(this.$player);try{b.initComponentsReadyState(this.$player)}catch(i){console.error("\u521D\u59CB\u5316\u7EC4\u4EF6ready\u65B9\u6CD5\u5931\u8D25:",i)}}},onsourceloaded(i){const t=i.paramData,e=t.desc,s=t.definition,n=this.$player.getComponent&&this.$player.getComponent("QualityComponent");n&&n.setCurrentQuality&&n.setCurrentQuality(e,s)},onerror(i){this.$emit("onerror",this.$player),this.config.onerror&&this.config.onerror(this.$player)},ontimeupdate(){this.onheart(),this.duration=this.$player.getDuration(),this.currentTime=this.$player.getCurrentTime(),this.$emit("ontimeupdate",this.duration,this.currentTime,this.$player),this.config.ontimeupdate&&this.config.ontimeupdate(this.duration,this.currentTime,this.$player)},onpause(){this.$emit("onpause",this.$player),this.config.onpause&&this.config.onpause(this.$player)},onplay(){this.$emit("onplay",this.$player),this.config.onplay&&this.config.onplay(this.$player)},onended(){this.onheart(!0),this.$emit("onended",this.$player),this.config.onended&&this.config.onended(this.$player)},onnext(){this.$emit("onnext",this.$player),this.config.onnext&&this.config.onnext(this.$player)},onpre(){this.$emit("onpre",this.$player),this.config.onpre&&this.config.onpre(this.$player)},onwaiting(){this.$emit("onwaiting",this.$player),this.config.onwaiting&&this.config.onwaiting(this.$player)},onsnapshoted(i){this.$emit("onsnapshoted",i,this.$player),this.config.onsnapshoted&&this.config.onsnapshoted(i,this.$player)},onheart(i){if(i)return this.$emit("onheart",this.$player),this.config.onheart&&this.config.onheart(this.$player),!1;if(this.onheart_lock)return!1;clearTimeout(this.timers[0]),this.timers[0]=null,this.onheart_lock=!0,this.timers[0]=setTimeout(()=>{this.onheart_lock=!1,this.$emit("onheart",this.$player),this.config.onheart&&this.config.onheart(this.$player)},this.hearttime)},destroy(){if(this.$player){clearTimeout(this.timers[0]||null),this.onheart_lock=!1,this.$player.off("ready",this.onready),this.$player.off("error",this.onerror),this.$player.off("timeupdate",this.ontimeupdate),this.$player.off("pause",this.onpause),this.$player.off("play",this.onplay),this.$player.off("ended",this.onended),this.$player.off("waiting",this.onwaiting),this.$player.off("snapshoted",this.onsnapshoted),this.$player.off("sourceloaded",this.onsourceloaded);try{b.destroyComponents(this.$player)}catch(i){console.error("\u9500\u6BC1\u7EC4\u4EF6\u5931\u8D25:",i)}this.$player.destroy(),this.$player=null,this.$playerBox.removeEventListener("keydown",this.onkeydown,!1),this.$playerBox.removeEventListener("keyup",this.onkeyup,!1),this._readyCalled=!1}},getCurrentTime(){return this.$player&&this.$player.getCurrentTime()||0},onkeydown(i){if(!this.$player)return!1;const t=i.target,e=!t.hasAttribute("contenteditable")&&!/INPUT|TEXTAREA/gi.test(t.tagName);(i.keyCode===13||i.keyCode===32)&&e?this.$player.getStatus()==="playing"?this.$player.pause():this.$player.play():(i.keyCode===37||i.keyCode===39)&&e&&(this._keySeekTime=this.getCurrentTime(),i.keyCode===37?this._keySeekTime-=5:this._keySeekTime+=5)},seekTo(i){this.$player&&this.$player.seek(Number(i)||0)},onkeyup(i){if(!this.$player)return!1;const t=i.target,e=!t.hasAttribute("contenteditable")&&!/INPUT|TEXTAREA/gi.test(t.tagName);if(!((i.keyCode===37||i.keyCode===39)&&!e)){if(this.config.notProgress&&i.keyCode===39)return this._keySeekTime=null,!1;if(i.keyCode===37||i.keyCode===39){const s=this.$player.getDuration();this._keySeekTime<=0?this._keySeekTime=0:this._keySeekTime>=s&&(this._keySeekTime=s-5),this.seekTo(this._keySeekTime),this._keySeekTime=null}}}}};class E{static init(t,e={}){if(!t)return console.error("TcPlayerSDK: \u5FC5\u987B\u63D0\u4F9B\u6709\u6548\u7684DOM\u9009\u62E9\u5668"),null;const s=document.querySelector(t);if(!s)return console.error(`TcPlayerSDK: \u65E0\u6CD5\u627E\u5230\u6307\u5B9A\u7684DOM\u5143\u7D20: ${t}`),null;const n=`tcplayer-${Date.now()}-${Math.floor(Math.random()*1e3)}`,r=document.createElement("div");r.style.width="100%",r.style.height="100%",s.appendChild(r);const o={app:null,vm:null,mountEl:r,container:s,config:e,playerReady:!1,readyCallbacks:[],playerInstance:null},h=d.createApp({render(){return d.h(X,{config:{...e,onready:a=>{console.log("\u64AD\u653E\u5668\u51C6\u5907\u5C31\u7EEA\uFF0C\u66F4\u65B0\u5B9E\u4F8B\u72B6\u6001"),o.playerReady=!0,o.playerInstance=a,o.readyCallbacks.forEach(u=>{try{u(a)}catch(c){console.error("\u64AD\u653E\u5668\u5C31\u7EEA\u56DE\u8C03\u6267\u884C\u5931\u8D25:",c)}}),o.readyCallbacks=[],e.onready&&e.onready(a)}}})}}),l=h.mount(r);return o.app=h,o.vm=l,this.instances[n]=o,n}static destroy(t){const e=this.instances[t];return e?(e.app.unmount(),e.mountEl&&e.mountEl.parentNode&&e.mountEl.parentNode.removeChild(e.mountEl),delete this.instances[t],!0):(console.warn(`TcPlayerSDK: \u627E\u4E0D\u5230ID\u4E3A ${t} \u7684\u5B9E\u4F8B`),!1)}static getInstance(t){return this.instances[t]||null}static getAllInstances(){return Object.keys(this.instances)}static getPlayer(t){const e=this.instances[t];if(!e)return null;if(e.playerReady&&e.playerInstance)return e.playerInstance;try{if(e.vm&&e.vm.$player)return e.vm.$player;if(e.vm&&e.vm._&&e.vm._.$player)return e.vm._.$player}catch(s){console.warn("\u65E0\u6CD5\u4ECEVue\u5B9E\u4F8B\u83B7\u53D6\u64AD\u653E\u5668:",s)}return null}static waitForPlayerReady(t){return new Promise((e,s)=>{const n=this.instances[t];if(!n){s(new Error(`\u627E\u4E0D\u5230ID\u4E3A ${t} \u7684\u5B9E\u4F8B`));return}if(n.playerReady&&n.playerInstance){e(n.playerInstance);return}n.readyCallbacks.push(e),setTimeout(()=>{const r=n.readyCallbacks.indexOf(e);r>-1&&(n.readyCallbacks.splice(r,1),s(new Error("\u7B49\u5F85\u64AD\u653E\u5668\u5C31\u7EEA\u8D85\u65F6")))},1e4)})}static isPlayerReady(t){const e=this.instances[t];return e?e.playerReady:!1}}return T(E,"version",d.version),T(E,"TcPlayerComponent",k),T(E,"isVue2",d.isVue2),T(E,"isVue3",d.isVue3),T(E,"instances",{}),typeof window<"u"&&(window.PsTcPlayer=E),E});