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

@ -5293,13 +5293,10 @@ class SoundManager {
constructor() { constructor() {
this.channels = {}; this.channels = {};
console.log("SoundManager construction");
if ('AudioContext' in window){ if ('AudioContext' in window){
console.log("SoundManager construction 2");
this.context = new AudioContext(); this.context = new AudioContext();
} }
else if ('webkitAudioContext' in window){ else if ('webkitAudioContext' in window){
console.log("SoundManager construction 3");
this.context = new webkitAudioContext(); this.context = new webkitAudioContext();
} }
else { else {
@ -5312,9 +5309,16 @@ class SoundManager {
console.log("onComplete from context", arguments); console.log("onComplete from context", arguments);
}; };
window.addEventListener("visibilitychange", () => { window.addEventListener("visibilitychange", (e) => {
console.log("visibility Change event", e);
this.handleVisibilityChange(); this.handleVisibilityChange();
}); });
//For safari
let checkVisibility = ()=>{
this.handleVisibilityChange();
setTimeout(checkVisibility, 500);
};
checkVisibility();
} }
isNotSuspended(){ isNotSuspended(){
@ -5431,6 +5435,7 @@ class SoundManager {
} }
handleVisibilityChange() { handleVisibilityChange() {
console.log("handling visibillity change...");
if (document.hidden) { if (document.hidden) {
this.stopAll(); this.stopAll();
} }
@ -7555,6 +7560,7 @@ class WordRotatorSettingFragment extends LocalStorageSettingsFragment {
localStorage.removeItem("levelCounter"); localStorage.removeItem("levelCounter");
localStorage.removeItem("tutorial-step"); localStorage.removeItem("tutorial-step");
(await WordRotatorDb.getInstance()).removeAll(WordRotatorDb.OBJECT_STORE.LEVEL); (await WordRotatorDb.getInstance()).removeAll(WordRotatorDb.OBJECT_STORE.LEVEL);
(await WordRotatorDb.getInstance()).removeAll(WordRotatorDb.OBJECT_STORE.SYSTEM_VARS);
}); });
if (location.hostname.includes("beta") || location.hostname.includes("127.0.0.1")) { if (location.hostname.includes("beta") || location.hostname.includes("127.0.0.1")) {
@ -7860,8 +7866,6 @@ InitPromise.resolve(app$1).then(async function () {
app$1.start(MenuSite); app$1.start(MenuSite);
Translator.setLanguage("de"); Translator.setLanguage("de");
InstallManager.setCanInstallListener(e => {}); InstallManager.setCanInstallListener(e => {});
let storageManager = MyStorageManager.getInstance(); let storageManager = MyStorageManager.getInstance();
if (InstallManager.isInstalled()){ if (InstallManager.isInstalled()){
@ -7871,7 +7875,7 @@ InitPromise.resolve(app$1).then(async function () {
window["applyAndroidBridge"] = AndroidBridge.applyDefinitions; window["applyAndroidBridge"] = AndroidBridge.applyDefinitions;
let wasOpened = (Helper.nonNull(localStorage.getItem('was-open'), "0") === "1"); let wasOpened = (Helper.nonNull(localStorage.getItem('was-open'), "0") === "1");
if (wasOpened){ if (wasOpened && storageManager.canPersist()){
Promise.all([storageManager.isPersistent(), navigator["serviceWorker"]["ready"]]).then(res => { Promise.all([storageManager.isPersistent(), navigator["serviceWorker"]["ready"]]).then(res => {
if (!res[0]){ if (!res[0]){
FlashMessenger.addMessage("warning-data-not-persistent"); FlashMessenger.addMessage("warning-data-not-persistent");

View File

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