提交 eb76a635 编写于 作者: Q qiang

feat: h5 video 增加 progress 事件

上级 580d4868
...@@ -57,7 +57,7 @@ ...@@ -57,7 +57,7 @@
> >
<div class="uni-video-progress"> <div class="uni-video-progress">
<div <div
:style="{width:buffered*100+'%'}" :style="{width:buffered+'%'}"
class="uni-video-progress-buffered" /> class="uni-video-progress-buffered" />
<div <div
ref="ball" ref="ball"
...@@ -313,6 +313,13 @@ export default { ...@@ -313,6 +313,13 @@ export default {
}, },
duration () { duration () {
this.updateProgress() this.updateProgress()
},
buffered (buffered) {
if (buffered !== 0) {
this.$trigger('progress', {}, {
buffered
})
}
} }
}, },
created () { created () {
...@@ -537,11 +544,13 @@ export default { ...@@ -537,11 +544,13 @@ export default {
height: video.videoHeight, height: video.videoHeight,
duration: video.duration duration: video.duration
}) })
this.onProgress($event)
}, },
onProgress ({ target }) { onProgress ($event) {
const buffered = target.buffered const video = $event.target
const buffered = video.buffered
if (buffered.length) { if (buffered.length) {
this.buffered = buffered.end(buffered.length - 1) / target.duration this.buffered = buffered.end(buffered.length - 1) / video.duration * 100
} }
}, },
onWaiting ($event) { onWaiting ($event) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册