不太了解Cookie。我只想让我的播放\暂停按钮记住它的状态,仅此而已。这是代码,请帮助。 谢谢
$('.video-control').on('click', function () {
$(this).toggleClass('video-control_active');
var currentVideo = document.querySelector('.play');
if (currentVideo.paused) {
currentVideo.play();
} else {
currentVideo.pause()
}
})
答案 0 :(得分:0)
以视频播放为名称读取cookie。
var youCookie = $.cookie('video-playing');
创建或/和更新cookie
$.cookie('video-playing', "true");
$.cookie('video-playing', "false");
答案 1 :(得分:0)
所以,我回到案子并读了一点。这对我有用:
if(localStorage.paused !== 'true') playlist();
else {
videos[currPlayVideo].classList.add('play');
videos[currPlayVideo].onended = function () {
playNextVideo();
};
$('.video-control').remove('video-control_active');
};
$('.video-control').on('click', function () {
var currentVideo = document.querySelector('.play');
$(this).toggleClass('video-control_active');
if (currentVideo.paused) {
currentVideo.play();
localStorage.paused = 'false'
} else {
currentVideo.pause();
localStorage.paused = 'true'
}
});
,并且要让“播放|暂停”按钮记住以下内容:
if (localStorage.getItem("paused") == "true") {
getFav = localStorage.paused;
$(".video-control").addClass('video-control_active');
}