zhw2590582 / ArtPlayer

:art: ArtPlayer.js is a modern and full featured HTML5 video player
https://artplayer.org
MIT License
2.49k stars 264 forks source link

save time progress to cookies every 5 seconds #725

Closed jedgarf closed 5 months ago

jedgarf commented 5 months ago

how to save video time progress to cookies every 5 seconds?

zhw2590582 commented 5 months ago

Like this?

var art = new Artplayer({
    container: '.artplayer-app',
    url: '/assets/sample/video.mp4',
});

let lastTime = 0;
art.on('video:timeupdate', () => {
    if (art.currentTime - lastTime >= 5) {
        console.log('save to cookies', art.currentTime);
        lastTime = art.currentTime;
    }
});
jedgarf commented 5 months ago

thank you