提交 07b6e8b2 authored 作者: 王鹏飞's avatar 王鹏飞

chore: 优化视频回放

上级 2657a6e5
...@@ -21,15 +21,15 @@ const hover = ref(false) ...@@ -21,15 +21,15 @@ const hover = ref(false)
onMounted(() => { onMounted(() => {
video.value.ondurationchange = (e) => { video.value.ondurationchange = (e) => {
if (e.target.duration === Infinity) { // if (e.target.duration === Infinity) {
video.value.currentTime = 1e101 // video.value.currentTime = 1e101
} else { // } else {
video.value.currentTime = 0 // video.value.currentTime = 0
} // }
duration.value = e.target.duration === Infinity ? parseFloat(record.value.live_duration) : e.target.duration duration.value = e.target.duration === Infinity ? parseFloat(record.value.live_duration) : e.target.duration
} }
video.value.ontimeupdate = () => { video.value.ontimeupdate = () => {
currentTime.value = video.value.currentTime currentTime.value = video.value?.currentTime || 0
} }
video.value.onplay = () => { video.value.onplay = () => {
playing.value = true playing.value = true
...@@ -48,6 +48,10 @@ onMounted(() => { ...@@ -48,6 +48,10 @@ onMounted(() => {
} }
}) })
onUnmounted(() => {
video.value?.pause()
})
const togglePlay = () => { const togglePlay = () => {
playing.value ? video.value?.pause() : video.value?.play() playing.value ? video.value?.pause() : video.value?.play()
} }
......
...@@ -93,7 +93,7 @@ export function useLive({ enabledUserMedia = true, onStart, onRecord, onStop }: ...@@ -93,7 +93,7 @@ export function useLive({ enabledUserMedia = true, onStart, onRecord, onStop }:
const start = () => { const start = () => {
if (!mediaRecorder) initializeMediaRecorder() if (!mediaRecorder) initializeMediaRecorder()
recordedChunks.value = [] recordedChunks.value = []
mediaRecorder?.start(1000) // 每100ms触发一次dataavailable事件 mediaRecorder?.start(5000) // 每100ms触发一次dataavailable事件
} }
// 停止录制 // 停止录制
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论