Skip to content

Commit

Permalink
fix(video): add new events time jd-opensource#1055 (jd-opensource#1798)
Browse files Browse the repository at this point in the history
  • Loading branch information
Drjingfubo authored Oct 27, 2022
1 parent 2073896 commit eedb043
Showing 3 changed files with 8 additions and 11 deletions.
3 changes: 2 additions & 1 deletion src/packages/__VUE/video/doc.en-US.md
Original file line number Diff line number Diff line change
@@ -264,4 +264,5 @@ export default {
|---------|------------------------------|-----------|
| play | play event | - |
| pause | pause event | - |
| playend | Playback completion callback | - |
| playend | Playback completion callback | - |
| time `v3.2.6` | Triggered when playing(current is the current playback time,total is the total time)|(current:string,total:string) |
3 changes: 2 additions & 1 deletion src/packages/__VUE/video/doc.md
Original file line number Diff line number Diff line change
@@ -265,4 +265,5 @@ export default {
| -------- | ------------ | -------- |
| play | 播放 | -- |
| pause | 暂停 | -- |
| playend | 播放完成回调 | -- |
| playend | 播放完成回调 | -- |
| time `v3.2.6` | 播放时触发(current为当前播放时间,total为总时间)| (current:string,total:string) |
13 changes: 4 additions & 9 deletions src/packages/__VUE/video/index.vue
Original file line number Diff line number Diff line change
@@ -90,7 +90,7 @@ export default create({
}
},
components: {},
emits: ['click', 'play', 'pause', 'playend'],
emits: ['click', 'play', 'pause', 'playend', 'time'],
setup(props, { emit }) {
const state = reactive({
@@ -187,10 +187,7 @@ export default create({
});
(state.videoElm as any).addEventListener('ended', playEnded);
// (state.videoElm as any).addEventListener(
// 'timeupdate',
// throttle(getPlayTime, 100, 1)
// );
(state.videoElm as any).addEventListener('timeupdate', throttle(getPlayTime, 1000, 1));
}
};
@@ -223,10 +220,7 @@ export default create({
getLoadTime();
});
// 监听播放进度
// (state.videoElm as any).addEventListener(
// 'timeupdate',
// throttle(getPlayTime, 100, 1)
// );
(state.videoElm as any).addEventListener('timeupdate', throttle(getPlayTime, 1000, 1));
// 监听结束
(state.videoElm as any).addEventListener('ended', playEnded);
emit('play', state.videoElm);
@@ -276,6 +270,7 @@ export default create({
// 赋值时长
state.videoSet.totalTime = timeFormat((state.videoElm as any).duration);
state.videoSet.displayTime = timeFormat((state.videoElm as any).currentTime);
emit('time', state.videoSet.displayTime, state.videoSet.totalTime);
};
const playEnded = () => {

0 comments on commit eedb043

Please sign in to comment.