Browse Source

remember current time of audio

master
filesite 4 months ago
parent
commit
290ddac015
  1. 25
      www/js/beauty.js

25
www/js/beauty.js

@ -267,6 +267,15 @@ $('.cleanCacheJS').click(function () { @@ -267,6 +267,15 @@ $('.cleanCacheJS').click(function () {
if ($('#music_main').length > 0) {
var musicState = 0;
$('#music_main').get(0).volume = 0.5; // 控制音量
$('#music_main').one('canplay', function() {
var cookieKey = 'audio_current_time';
var currentTime = Cookies.get(cookieKey);
if (currentTime > 0) {
this.currentTime = currentTime;
$('.musicJS').addClass('music_put');
}
});
$('.musicJS').click(function () {
if (musicState == 0) {
$('#music_main').get(0).play();
@ -285,6 +294,22 @@ if ($('#music_main').length > 0) { @@ -285,6 +294,22 @@ if ($('#music_main').length > 0) {
$('.musicJS').addClass('music_put');
musicState = 1;
});
$(window).on('beforeunload', function() {
$('#music_main').get(0).volume = 0.2; // 减小音量
var currentTime = $('#music_main').get(0).currentTime;
var cookieKey = 'audio_current_time';
Cookies.set(cookieKey, currentTime, { expires: 1 });
});
$(document.body).click(function(evt) {
var elA = $(evt.target).parents('a');
if (elA.length > 0 && elA.attr('target') == '_blank') { //点击视频暂停音乐
$('#music_main').get(0).pause();
$('.musicJS').removeClass('music_put');
musicState = 0;
}
});
}
//二维码显示

Loading…
Cancel
Save