handleVisibility-Bug für Safari behoben
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user