HLS模式下,如何改变播放器的状态
turnmind opened this issue · 0 comments
turnmind commented
使用 Vue3 开发, HLS工作后,如何设置播放器为直播状态,防止进度条乱跳
<template>
<NPlayer
:options="state.options.player"
:set="setPlayer"
/>
</template>
<script setup>
import HLS from 'hls.js'
const state = reactive({
options: {
player: { live: true, plugins: [] }
}
})
let mNPlayer = null
const hls = new HLS()
const setPlayer = (p) => mNPlayer = p
function getVideoInfo() {
hls.loadSource('M3u8 Stream Url...')
hls.attachMedia(mNPlayer.video)
// 更新为直播状态
mNPlayer.updateOptions({ live: true })
}
onMounted(() => {
getVideoInfo()
})
</script>