import{b as n,a as c,n as r}from"./property-ChPqBGW_.js";import{t as h}from"./custom-element-C-crYl4r.js";import{e as u}from"./query-BYlH-2gt.js";import{B as d}from"./base-element-8qyqvBFG.js";import{L as f}from"./live-player-6SvZDb9M.js";import"./index-DWRYsVdq.js";import"./base-player-BWJBhwy4.js";import"./time-BQ1bZM2l.js";import"./flv-demuxer-D42STsrK.js";var m=Object.defineProperty,b=Object.getOwnPropertyDescriptor,t=(o,i,a,p)=>{for(var s=p>1?void 0:p?b(i,a):i,l=o.length-1,y;l>=0;l--)(y=o[l])&&(s=(p?y(i,a,s):y(s))||s);return p&&s&&m(i,a,s),s};let e=class extends d{constructor(){super("M7SLivePlayerElement"),this.src="",this.controls=!1,this.autoplay=!1,this.debug=!1,this.showPlaybackRate=!1,this.showProgress=!1,this.lang="zh-CN",this.protocol="auto",this.demuxerType="auto",this.useHardwareDecoder=!0,this.reconnect=!0,this.reconnectDelay=3e3,this.bufferTime=1e3,this.player=null}onInitialize(){this.initPlayer()}onDisconnect(){this.disposePlayer()}updated(o){["debug","protocol","demuxerType","useHardwareDecoder","reconnect","reconnectDelay","bufferTime"].some(a=>o.has(a))&&this.initPlayer(!0),o.has("src")&&this.src&&this.loadSource()}initPlayer(o=!1){this.videoEl&&(o&&this.disposePlayer(),!this.player&&(this.player=new f({autoplay:this.autoplay,debug:this.debug,protocol:this.protocol,demuxerType:this.demuxerType,decoderType:this.useHardwareDecoder?"auto":"soft",reconnect:this.reconnect,reconnectDelay:this.reconnectDelay,bufferTime:this.bufferTime}),this.player.attachVideo(this.videoEl),this.player.on("play",()=>this.dispatchCustomEvent("play")),this.player.on("pause",()=>this.dispatchCustomEvent("pause")),this.player.on("timeupdate",i=>this.dispatchCustomEvent("timeupdate",i)),this.player.on("error",i=>this.dispatchCustomEvent("error",{error:i}))))}async loadSource(){if(!(!this.player||!this.src))try{await this.player.load(this.src)}catch(o){this.dispatchCustomEvent("error",{error:o})}}disposePlayer(){if(this.player){try{this.player.dispose()}catch{}this.player=null}}async play(){this.player&&await this.player.play()}pause(){this.player&&this.player.pause()}render(){return n`
      <div class="container">
        <video playsinline></video>
      </div>
    `}};e.styles=c`
    :host {
      display: block;
      width: 100%;
      position: relative;
    }

    .container {
      position: relative;
      width: 100%;
      background: #000;
      aspect-ratio: 16 / 9;
    }

    video {
      width: 100%;
      height: 100%;
      object-fit: contain;
    }
  `;t([r({type:String})],e.prototype,"src",2);t([r({type:Boolean,reflect:!0})],e.prototype,"controls",2);t([r({type:Boolean})],e.prototype,"autoplay",2);t([r({type:Boolean})],e.prototype,"debug",2);t([r({type:Boolean,attribute:"show-playback-rate"})],e.prototype,"showPlaybackRate",2);t([r({type:Boolean,attribute:"show-progress"})],e.prototype,"showProgress",2);t([r({type:String})],e.prototype,"lang",2);t([r({type:String})],e.prototype,"protocol",2);t([r({type:String,attribute:"demuxer-type"})],e.prototype,"demuxerType",2);t([r({type:Boolean,attribute:"use-hardware-decoder"})],e.prototype,"useHardwareDecoder",2);t([r({type:Boolean})],e.prototype,"reconnect",2);t([r({type:Number,attribute:"reconnect-delay"})],e.prototype,"reconnectDelay",2);t([r({type:Number,attribute:"buffer-time"})],e.prototype,"bufferTime",2);t([u("video")],e.prototype,"videoEl",2);e=t([h("m7s-live-player")],e);export{e as M7SLivePlayerElement};
