<template>
<div>
<video ref="videoRef"></video>
</div>
</template>
<script>
import videojs from 'video.js';
export default {
name: "videoRef",
props: {
options: {
type: Object,
default() {
return {};
}
}
},
data() {
return {
player: null
}
},
mounted() {
this.player = videojs(this.$refs.videoRef, this.options, function onPlayerReady() {
console.log('onPlayerReady', this);
})
//每次时间更新的时候调用该方法
this.player.on('timeupdate', ()=> {
var currentTime = this.player.currentTime(); // 获取当前播放时间
// console.log(currentTime);
if(currentTime > 9.7) {
this.player.currentTime(4.49);
}
});
},
beforeDestroy() {
if (this.player) {
this.player.dispose()
}
}
}
</script>
11-26
5286
11-12