我正在尝试创建一个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 API至store 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);
});
});