mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-10 12:46:15 -08:00
21 lines
630 B
JavaScript
21 lines
630 B
JavaScript
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.innerText) {
|
|
$control.innerText = newTime;
|
|
}
|
|
}
|
|
|
|
getTime();
|
|
['video:loadedmetadata', 'video:timeupdate', 'video:progress'].forEach(event => {
|
|
art.on(event, getTime);
|
|
});
|
|
},
|
|
});
|
|
}
|