Skip to content

Commit

Permalink
Merge pull request #6 from ArrowComputingTech/ArrowComputingTech-volu…
Browse files Browse the repository at this point in the history
…mecookie

Added cookie for volume adjustment.
  • Loading branch information
lrkrol authored Oct 27, 2022
2 parents cbf2ac7 + 62c1e20 commit 8426331
Showing 1 changed file with 31 additions and 9 deletions.
40 changes: 31 additions & 9 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
error_reporting( 0 );

/*
Noctifer Music 0.6.1
Copyright 2019 Laurens R Krol
Noctifer Music 0.7.0
Copyright 2019, 2022 Laurens R. Krol
noctifer.net, lrkrol.com
This program is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -81,6 +81,10 @@
# | C H A N G E L O G |
# +---------------------------+
2022-10-27 0.7.0
- Added cookie to maintain volume when changed
- Minor cleanup
2019-04-08 0.6.1
- Added keyboard shortcuts and swipe events
- Also password-protected playlist view
Expand Down Expand Up @@ -218,7 +222,7 @@
<input type="password" name="password" id="passwordinput" />
<input type="submit" value="Submit" />
</form>
</div></div>';
</div></div>
PASSWORDREQUEST;
} else {

Expand Down Expand Up @@ -839,15 +843,27 @@ function getCookie(cname) {
};
document.addEventListener("DOMContentLoaded", function() {
document.getElementById('audio').addEventListener('error', function() {
var audio = document.getElementById('audio');
audio.addEventListener('error', function() {
document.getElementById('error').innerHTML = 'Playback error';
document.getElementById('error').style.display = 'block';
setTimeout(function(){ advance('next'); }, 2000);
});
document.getElementById('audio').addEventListener('ended', function() {
audio.addEventListener('ended', function() {
advance('next');
});
audio.addEventListener('volumechange', function() {
setCookie('nm_volume', audio.volume, 14);
});
var volume = getCookie('nm_volume');
if (volume != null && volume) {
audio.volume = volume;
}
{$onloadgoto}
}, false);
Expand Down Expand Up @@ -882,9 +898,6 @@ function getCookie(cname) {
case 39: // right
advance('next');
break;
case 13: // enter
toggleView('$photoUrl');
break;
}
};
Expand Down Expand Up @@ -926,6 +939,15 @@ function swipedetect(el, callback){
advance('previous');
}
})
// Get and set volume with cookie
var audio = document.getElementById('audio');
audio.addEventListener('volumechange', function() {
setCookie('volume', audio.volume, 14);
});
var volume = getCookie('volume');
if (volume != null && volume) {
audio.volume = volume;
}
}, false);
</script>
Expand Down Expand Up @@ -1217,4 +1239,4 @@ function swipedetect(el, callback){
HTML;
}

?>
?>

0 comments on commit 8426331

Please sign in to comment.