Commit b454059c authored by Bui's avatar Bui Committed by GitHub

Merge pull request #44 from LoveEevee/fix-audioctx-safari

SoundBuffer: Fix AudioContext on Safari again
parents c0db4119 8565318c
......@@ -3,7 +3,7 @@
var AudioContext = window.AudioContext || window.webkitAudioContext
this.context = new AudioContext()
pageEvents.once(window, "click").then(() => {
if(this.context.state == "suspended"){
if(this.context.state === "suspended"){
this.context.resume()
}
})
......@@ -12,7 +12,9 @@
return loader.ajax(url, request => {
request.responseType = "arraybuffer"
}).then(response => {
return this.context.decodeAudioData(response)
return new Promise((resolve, reject) => {
return this.context.decodeAudioData(response, resolve, reject)
})
}).then(buffer => {
return new Sound(gain || {soundBuffer: this}, buffer)
})
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment