stop player on hide/unhide

This commit is contained in:
Puniko 2022-12-29 21:01:35 +01:00
parent 6b7f13e8ef
commit 79f546d150

View file

@ -117,15 +117,17 @@ function playPause() {
} }
} }
function stop() { function stop(noDisplayUpdate = false) {
player.value.stop(); player.value.stop();
playing.value = false; playing.value = false;
if (!noDisplayUpdate) {
try { try {
player.value.play(buffer); player.value.play(buffer);
display(); display();
} catch (e) { } catch (e) {
console.warn(e); console.warn(e);
} }
}
player.value.stop(); player.value.stop();
position.value = 0; position.value = 0;
player.value.handlers = []; player.value.handlers = [];
@ -143,6 +145,7 @@ function performSeek() {
function toggleVisible() { function toggleVisible() {
hide.value = !hide.value; hide.value = !hide.value;
stop(true);
} }
function display() { function display() {