gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-30 19:00:45 25 4
gpt4 key购买 nike

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

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

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

最佳答案

您已经知道需要什么积木了,现在只需要把它们拼在一起即可。

随着Vimeo Player API ,您可以获取 vimeo 实例和 get the player time when the video pauses .

然后使用 localStorage APIstore the data .

加载页面时,只需check localStorage if data is present并再次使用 Vimeo Player API 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);
});
});

关于javascript - 如何使用 localStorage 恢复页面重新加载时 vimeo 的暂停时间?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59530620/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com