mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-10 21:06:15 -08:00
32 lines
932 B
JavaScript
32 lines
932 B
JavaScript
import { secondToTime, isMobile } from '../utils';
|
|
|
|
export default function time(option) {
|
|
return (art) => ({
|
|
...option,
|
|
style: isMobile
|
|
? {
|
|
fontSize: '12px',
|
|
padding: '0 5px',
|
|
}
|
|
: {
|
|
cursor: 'auto',
|
|
padding: '0 10px',
|
|
},
|
|
mounted: ($control) => {
|
|
function getTime() {
|
|
const newTime = `${secondToTime(art.currentTime)} / ${secondToTime(art.duration)}`;
|
|
if (newTime !== $control.innerText) {
|
|
$control.innerText = newTime;
|
|
}
|
|
}
|
|
|
|
getTime();
|
|
|
|
const events = ['video:loadedmetadata', 'video:timeupdate', 'video:progress'];
|
|
for (let index = 0; index < events.length; index++) {
|
|
art.on(events[index], getTime);
|
|
}
|
|
},
|
|
});
|
|
}
|