解决延迟问题

merge-requests/1/head
dydwang 5 years ago
parent 5d40a43e55
commit cdcca5137f

@ -7,9 +7,9 @@
<meta name="viewport" content="width=device-width,initial-scale=1.0"> <meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="<%= BASE_URL %>favicon.ico"> <link rel="icon" href="<%= BASE_URL %>favicon.ico">
<!-- 加快视频的响应速度--> <!-- 加快视频的响应速度-->
<link href="/static/video-js-cdn.min.css" rel="stylesheet"> <link href="/video_play_plugins/video-js-cdn.min.css" rel="stylesheet">
<script src="/static/video.js"></script> <script src="/video_play_plugins/video.js"></script>
<script src="/static/videojs-contrib-hls.min.js"></script> <script src="/video_play_plugins/videojs-contrib-hls.min.js"></script>
<title>垛机视觉系统</title> <title>垛机视觉系统</title>
</head> </head>

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

@ -1,10 +1,12 @@
<template> <template>
<video-player <video-player
v-if="showVideo"
ref="video-player" ref="video-player"
class="vjs-custom-skin" class="vjs-custom-skin"
:options="playerOptions" :options="playerOptions"
@pause="onPlayerPause" @pause="onPlayerPause"
@playing="onPlayerPlaying" @playing="onPlayerPlaying"
@timeupdate="onPlayerTimeupdate"
@ended="onPlayerEnded" @ended="onPlayerEnded"
/> />
</template> </template>
@ -27,6 +29,7 @@ export default {
}, },
data() { data() {
return { return {
showVideo: true,
isPlay: false, // 是否正在播放 isPlay: false, // 是否正在播放
playerOptions: { playerOptions: {
sources: [{ sources: [{
@ -74,6 +77,20 @@ export default {
onPlayerEnded($event) { onPlayerEnded($event) {
this.isPlay = false; this.isPlay = false;
}, },
// 播放
onPlayerTimeupdate($event) {
const bufferedEnd = $event.bufferedEnd();
const currentTime = $event.currentTime();
// 延迟时间
const differTime = bufferedEnd - currentTime
// 超过延迟重新加载
if(differTime > 60) {
this.showVideo = false;
this.$nextTick(() => {
this.showVideo = true;
})
}
}
} }
} }
</script> </script>

Loading…
Cancel
Save