|
|
|
@ -29,6 +29,8 @@ function SoundManager(core) { |
|
|
|
|
this.song = null; |
|
|
|
|
|
|
|
|
|
this.initPromise = null; |
|
|
|
|
this.lockedPromise = null; |
|
|
|
|
this.locked = true; |
|
|
|
|
|
|
|
|
|
/* Lower level audio and timing info */ |
|
|
|
|
this.context = null; // Audio context, Web Audio API
|
|
|
|
@ -112,7 +114,17 @@ SoundManager.prototype.init = function() { |
|
|
|
|
audioWorker.postMessage({ping:true, ogg:this.oggSupport}); |
|
|
|
|
}); |
|
|
|
|
}).then(() => { |
|
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
|
this.locked = this.context.state != "running"; |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
return this.initPromise; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
SoundManager.prototype.unlock = function() { |
|
|
|
|
if(this.lockedPromise) { |
|
|
|
|
return this.lockedPromise; |
|
|
|
|
} |
|
|
|
|
this.lockedPromise = new Promise((resolve, reject) => { |
|
|
|
|
// iOS and other some mobile browsers - unlock the context as
|
|
|
|
|
// it starts in a suspended state
|
|
|
|
|
let unlocker = () => { |
|
|
|
@ -135,10 +147,8 @@ SoundManager.prototype.init = function() { |
|
|
|
|
window.addEventListener('touchend', unlocker, false); |
|
|
|
|
window.addEventListener('click', unlocker, false); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
return this.lockedPromise; |
|
|
|
|
} |
|
|
|
|
return this.initPromise; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
SoundManager.prototype.playSong = function(song, playBuild, forcePlay) { |
|
|
|
|
let p = Promise.resolve(); |
|
|
|
|