index-570cc16d.js 3.8 KB

1
  1. import{d as r,a as n}from"./index-521a9826.js";import{T as l}from"./tcplayer.v4.8.0.min-e19fa46b.js";const a="_video_v70ny_1",p="_loadingVideo_v70ny_43",y="_playOver_v70ny_52",d="_tips_v70ny_60",c="_btn_v70ny_64",u="_replay_v70ny_71",h="_freeTxt_v70ny_74",f="_freeRate_v70ny_80",o={"video-container":"_video-container_v70ny_1",video:a,loadingVideo:p,playOver:y,tips:d,btn:c,replay:u,freeTxt:h,freeRate:f};const g=r({name:"o-video",props:{setting:{type:Object,default:()=>{}},controls:{type:Boolean,default:!0},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},onPlay:{type:Function,default:()=>{}}},emits:["exitfullscreen"],data(){return{videoID:"video"+Date.now()+Math.floor(Math.random()*100),player:null,loading:!0}},mounted(){this._init()},methods:{_init(){const i=l.getComponent("Button"),t=l.getComponent("BigPlayButton");t.prototype.createEl=function(){const e=i.prototype.createEl.call(this),s='<button><svg width="41px"height="41px"viewBox="0 0 41 41"version="1.1"xmlns="http://www.w3.org/2000/svg"xmlns:xlink="http://www.w3.org/1999/xlink"><g stroke="none"stroke-width="1"fill="none"fill-rule="evenodd"><g transform="translate(-167.000000, -155.000000)"><g transform="translate(0.000000, 85.000000)"><g transform="translate(158.000000, 70.000000)"><g transform="translate(9.000000, 0.000000)"><circle id="椭圆形"stroke="#FFFFFF"fill-opacity="0.1"fill="#D8D8D8"cx="20.5"cy="20.5"r="20"></circle><path d="M14.5483871,27.6859997 L14.5483871,13.4342349 C14.5480523,12.8729571 14.8729597,12.356555 15.3949624,12.0887034 C15.9169651,11.8208518 16.5522696,11.8445472 17.0503046,12.1504437 L28.6530473,19.2778563 C29.1119763,19.5602271 29.3887725,20.0426422 29.3887725,20.5601173 C29.3887725,21.0775924 29.1119763,21.5600075 28.6530473,21.8423783 L17.0503046,28.9697909 C16.5522696,29.2756874 15.9169651,29.2993828 15.3949624,29.0315312 C14.8729597,28.7636796 14.5480523,28.2472775 14.5483871,27.6859997 Z"id="路径"fill="#FFFFFF"fill-rule="nonzero"></path></g></g></g></g></g></svg></button>';return e.appendChild(l.dom.createEl("div",{className:"vjs-button-icon",innerHTML:s})),e},this.player=l(this.videoID,{appID:"",controls:this.controls}),this.player&&(this.player.src(this.src),this.player.poster(this.poster||""),this.preload==="none"&&(this.loading=!1),this.player.on("loadstart",()=>{this.loading=!1,this.domPlayVisibility(!1)}),this.player.on("play",()=>{this.onPlay&&this.onPlay(this.player)}),this.player.on("fullscreenchange",()=>{if(this.player.isFullscreen()){console.log("fullscreen");const e=document.createElement("i");e.id="fullscreen-back",e.className="van-icon van-icon-arrow-left video-back",e.addEventListener("click",()=>{this.player.exitFullscreen()}),document.getElementsByClassName("video-js")[0].appendChild(e)}else{console.log("exitfullscreen");const e=document.getElementById("fullscreen-back");e&&e.remove()}}))},domPlayVisibility(i=!0){const t=document.querySelector(".vjs-big-play-button"),e=document.querySelector(".vjs-control-bar");i?(t==null||t.setAttribute("style","display:none"),e==null||e.setAttribute("style","display:none")):(t==null||t.removeAttribute("style"),setTimeout(()=>{e==null||e.removeAttribute("style")},200))},onReplay(){this.player.currentTime(0),this.player.play(),this.domPlayVisibility(!1)},onStop(){this.player.currentTime(0),this.player.pause()}},unmounted(){var i,t,e;(i=this.player)==null||i.pause(),(t=this.player)==null||t.src(""),(e=this.player)==null||e.dispose()},render(){return n("div",{class:o["video-container"]},[n("video",{ref:"video",id:this.videoID,class:o.video,src:this.src,playsinline:this.playsinline,poster:this.poster,preload:this.preload,style:{...this.styleValue}},null)])}});export{g as M};