-videojs-markers给视频进度条标记

时间:2025-01-20 13:00:24
<script> import 'videojs-markers' /* eslint-disable */ export default { data() { return { options: { autoplay: 'muted',//自动播放 height: 500, width: 800, controls: true,//用户可以与之交互的控件 loop:true,//视频一结束就重新开始 muted:false,//默认情况下将使所有音频静音 playsinline: true, webkitPlaysinline: true, // aspectRatio:"16:9",//显示比率 playbackRates: [0.5, 1, 1.5, 2], fullscreen:{ options: {navigationUI: 'hide'} }, sources: [ { src: '/v/oceans.mp4', type: "video/mp4" }, ] }, player: null } }, mounted() { this.player = this.$video(this.$refs.videoPlayer, this.options, function onPlayerReady() { console.log('onPlayerReady', this); }) // 设置标点 this.player.markers({ // 不显示鼠标悬浮标记提示文字 markerTip: { display: false }, markerStyle: { 'width':'7px', 'background-color': 'red', 'border-radius': '50%', }, markers: [ { time: 0.694313, class: 'custom-marker-class' }, { time: 5.694313, class: 'custom-marker-class' }, { time: 10.694313, class: 'custom-marker-class' }, { time: 15.694313, class: 'custom-marker-class' } ] }); // 获取当前播放时间 this.player.on("timeupdate", function(event) { console.log(this.currentTime()); }); }, methods: { onPrev () { this.player.markers.prev() }, onNext() { this.player.markers.next() } }, beforeDestroy() { if (this.player) { this.player.dispose() } }, } </script>