如何使用 localStorage 恢复页面重新加载时 vimeo 的暂停时间?

How to restore the pause time of vimeo on page reload using localStorage?

我正在尝试创建一个 jquery 脚本来存储 vimeo 视频的暂停时间,以便他回来时可以从他离开的地方观看它

jQuery(document).ready(function() {
    player.on('pause', function() {
        console.log("pause");   
    });
});

我想使用本地存储来实现这个

您已经想好需要什么积木了,现在您只需要将它们拼在一起即可。

随着 Vimeo Player API, you can fetch the vimeo instance and get the player time when the video pauses.

然后使用localStorage API to store the data.

加载页面时,如果是 check localStorage if data is present and use the Vimeo Player API again to set the current time

let time = localStorage.getItem('videoProgress');
if(time != null) {
    player.setCurrentTime(time);
}

player.on('pause', function() {
    player.getCurrentTime().then(function(seconds) {
        localStorage.setItem('videoProgress', seconds);
    });
});