handleVisibility-Bug für Safari behoben

This commit is contained in:
silas
2018-11-09 18:12:08 +01:00
parent dde9ae8223
commit f2290a8ff2
2 changed files with 20 additions and 11 deletions

View File

@@ -440,13 +440,10 @@ class SoundManager {
constructor() {
this.channels = {};
console.log("SoundManager construction");
if ('AudioContext' in window){
console.log("SoundManager construction 2");
this.context = new AudioContext();
}
else if ('webkitAudioContext' in window){
console.log("SoundManager construction 3");
this.context = new webkitAudioContext();
}
else {
@@ -459,9 +456,16 @@ class SoundManager {
console.log("onComplete from context", arguments);
};
window.addEventListener("visibilitychange", () => {
window.addEventListener("visibilitychange", (e) => {
console.log("visibility Change event", e);
this.handleVisibilityChange();
});
//For safari
let checkVisibility = ()=>{
this.handleVisibilityChange();
setTimeout(checkVisibility, 500);
};
checkVisibility();
}
isNotSuspended(){
@@ -578,6 +582,7 @@ class SoundManager {
}
handleVisibilityChange() {
console.log("handling visibillity change...");
if (document.hidden) {
this.stopAll();
}