| 1 |
- (window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-05420405"],{2142:function(e,t,i){"use strict";i.r(t);var n=function(){var e=this,t=e.$createElement,i=e._self._c||t;return i("div",{staticClass:"mainBox"},[e.videoUrl?i("video",{ref:"videoElement",attrs:{controls:e.showNativeControls,muted:"",controlsList:"noplaybackrate"},domProps:{muted:!0}}):i("el-empty",{style:{height:"100%",background:"#000000",display:"flex",justifyContent:"center",alignItems:"center"},attrs:{image:e.emptyImg}},[i("span",{staticStyle:{color:"white"},attrs:{slot:"description"},slot:"description"},[e._v("当前无可播放的录像资源")])])],1)},s=[],o=i("a567"),a=i("c4bf"),r=i.n(a),d={name:"videoBox",props:{videoUrl:{type:String,default:""},showNativeControls:{type:Boolean,default:!0}},data:function(){return{emptyImg:r.a,hls:null,video:null}},mounted:function(){var e=this;this.videoUrl&&this.$nextTick((function(){e.video=e.$refs.videoElement,e.addVideoListeners(),e.initPlayer(e.videoUrl)}))},beforeDestroy:function(){this.destroyPlayer(),this.removeVideoListeners()},methods:{pausePlayback:function(){this.video&&this.video.pause()},resumePlayback:function(){this.video&&this.video.play().catch((function(e){console.warn("浏览器策略阻止了自动播放:",e)}))},play:function(e){var t=this;this.$nextTick((function(){t.$refs.videoElement?(t.video=t.$refs.videoElement,t.addVideoListeners(),t.initPlayer(e)):console.error("videoElement 尚未渲染, play 失败")}))},initPlayer:function(e){var t=this;this.destroyPlayer(),e&&this.video?(console.log("videoBox 正在初始化播放,URL:",e),o["a"].isSupported()?(this.hls=new o["a"],this.hls.loadSource(e),this.hls.attachMedia(this.video),this.hls.on(o["a"].Events.MANIFEST_PARSED,(function(){t.video.play().catch((function(e){console.warn("浏览器策略阻止了自动播放:",e)}))})),this.hls.on(o["a"].Events.ERROR,(function(e,t){t.fatal&&console.error("HLS 致命错误:",t.type,t.details)}))):this.video.canPlayType("application/vnd.apple.mpegurl")?(this.video.src=e,this.video.play().catch((function(e){console.warn("浏览器策略阻止了自动播放:",e)}))):this.$message.error("当前浏览器不支持 HLS 播放")):console.warn("initPlayer 中断: URL 或 video 元素缺失")},destroyPlayer:function(){this.hls&&(this.hls.destroy(),this.hls=null),this.video&&(this.video.pause(),this.video.src="",this.video.removeAttribute("src"))},addVideoListeners:function(){this.video&&(this.removeVideoListeners(),this.video.addEventListener("play",this.onPlay),this.video.addEventListener("pause",this.onPause),this.video.addEventListener("ratechange",this.onRateChange),this.video.addEventListener("playing",this.onPlaying),this.video.addEventListener("waiting",this.onWaiting),this.video.addEventListener("ended",this.onEnded))},removeVideoListeners:function(){var e=this.$refs.videoElement;e&&(e.removeEventListener("play",this.onPlay),e.removeEventListener("pause",this.onPause),e.removeEventListener("ratechange",this.onRateChange),e.removeEventListener("playing",this.onPlaying),e.removeEventListener("waiting",this.onWaiting),e.removeEventListener("ended",this.onEnded))},onPlay:function(){this.$emit("playStatus","play",this.video.playbackRate),this.$emit("player-ready")},onPause:function(){this.$emit("playStatus","pause")},onRateChange:function(){this.$emit("playStatus","play",this.video.playbackRate)},onPlaying:function(){this.$emit("playStatus","play",this.video.playbackRate)},onWaiting:function(){this.$emit("playStatus","pause")},onEnded:function(){this.$emit("playbackCompleted")}}},l=d,h=(i("d944"),i("2877")),c=Object(h["a"])(l,n,s,!1,null,"22153b67",null);t["default"]=c.exports},bb8f:function(e,t,i){},c4bf:function(e,t,i){e.exports=i.p+"static/img/play.91da1167.png"},d944:function(e,t,i){"use strict";i("bb8f")}}]);
|