import{P as r}from"./plyr.min-a24de5e8.js";import{d as a,p as o,g as l,at as n,h as d}from"./index-bc617d61.js";const p="_video_1hxfx_1",y="_loadingVideo_1hxfx_35",s={"video-container":"_video-container_1hxfx_1",video:p,loadingVideo:y},c=a({name:"m-video",props:{setting:{type:Object,default:()=>({})},controls:Boolean,height:String,src:{type:String,default:""},poster:{type:String,default:""},styleValue:{type:Object,default:()=>({})},preload:{type:String,default:"auto"},currentTime:{type:Boolean,default:!0},playsinline:{type:Boolean,default:!0},preLoading:{type:Boolean,default:!0}},emits:["exitfullscreen","play","ready","enterfullscreen"],data(){return{player:null,loading:!0}},mounted(){this.loading=this.preLoading,this._init()},methods:{_init(){const e=["play-large","play","progress","captions","fullscreen"];this.currentTime&&e.push("current-time");const t={controls:e,...this.setting,invertTime:!1};o().iPhone&&(t.fullscreen={enabled:!0,fallback:"force",iosNative:!0}),this.player=new r(this.$refs.video,t),this.player.elements.container&&(this.player.elements.container.style.height=this.height||"210px"),this.preload==="none"&&(this.loading=!1),this.player.on("loadedmetadata",()=>{this.loading=!1,this.domPlayVisibility(!1)}),this.player.on("loadeddata",()=>{this.$emit("ready",this.player)}),this.player.on("play",()=>{this.$emit("play",this.player)}),this.player.on("enterfullscreen",()=>{this.$emit("enterfullscreen")}),this.player.on("exitfullscreen",()=>{console.log("exitfullscreen"),this.$emit("exitfullscreen")})},domPlayVisibility(e=!0){const t=document.querySelector(".plyr__controls"),i=document.querySelector(".plyr__control--overlaid");e?(t==null||t.setAttribute("style","display:none"),i==null||i.setAttribute("style","display:none")):(t==null||t.removeAttribute("style"),setTimeout(()=>{i==null||i.removeAttribute("style")},200))},onStop(){this.player.stop()},onExitScreen(){this.player.fullscreen.active&&this.player.fullscreen.exit()},onPlay(){var e;(e=this.player)==null||e.play()}},unmounted(){var e;(e=this.player)==null||e.destroy()},render(){return l("div",{class:s["video-container"]},[l("video",{ref:"video",class:s.video,src:this.src,playsinline:this.playsinline,poster:this.poster,preload:this.preload,style:{...this.styleValue}},null),this.loading&&l("div",{class:s.loadingVideo,style:{height:this.height||"210px"}},[l(n,{size:36,color:"#FF8057",vertical:!0,style:{height:"100%",justifyContent:"center"}},{default:()=>[d("加载中...")]})])])}});export{c as M};
