mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-24 06:31:20 -08:00
组件添加add方法
This commit is contained in:
1 parent
1d859e2049
commit
2fcd44e8e7
28 files changed
+303
-328
No files matched your search
@@ -0,0 +1,20 @@
|
||||
import { secondToTime } from '../utils';
|
||||
|
||||
export default function time(option) {
|
||||
return art => ({
|
||||
...option,
|
||||
mounted: $control => {
|
||||
function getTime() {
|
||||
const newTime = `${secondToTime(art.player.currentTime)} / ${secondToTime(art.player.duration)}`;
|
||||
if (newTime !== $control.innerHTML) {
|
||||
$control.innerHTML = newTime;
|
||||
}
|
||||
}
|
||||
|
||||
getTime();
|
||||
['video:loadedmetadata', 'video:timeupdate', 'video:progress'].forEach(event => {
|
||||
art.on(event, getTime);
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user