关于vue3中video标记(videojs和videojs-markers)
  g34dMbYVqWAh 2023年11月02日 78 0
1、首先安装
npm install videojs
npm install videojs-markers
2、页面引入
import videojs from 'video.js'
import 'video.js/dist/video-js.css'
import 'videojs-markers/dist/videojs.markers.css'
import 'videojs-markers'
3、html
<video  ref="videoPlayer" class=" video video-js vjs-default-skin vjs-big-play-centered"></video>
4、javascript
const videoPlayer = ref(null)
const player = ref(null)
const options = ref({
    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: 'http://vjs.zencdn.net/v/oceans.mp4',
            type: "video/mp4"
        },
    ]
})
const init = () => { 
    player.value = videojs(
        videoPlayer.value,
        options.value,
        function onPlayerReady() {
            console.log('onPlayerReady')
        }
    )
    player.value.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'
            }
        ]
    });
    player.value.on("timeupdate", function (event) {
        console.log(this.currentTime());
    });
}

onMounted(() => {
    nextTick(() => {
        init()
    })
})

5、结果展示

关于vue3中video标记(videojs和videojs-markers)_css


【版权声明】本文内容来自摩杜云社区用户原创、第三方投稿、转载,内容版权归原作者所有。本网站的目的在于传递更多信息,不拥有版权,亦不承担相应法律责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@moduyun.com

  1. 分享:
最后一次编辑于 2023年11月08日 0

暂无评论

推荐阅读
g34dMbYVqWAh