Skip to content

Commit

Permalink
Merge pull request goldfire#988 from Megabyteceer/master
Browse files Browse the repository at this point in the history
Fix for issue goldfire#986 handling decodeAudioData events in latest chrome
  • Loading branch information
goldfire authored Jul 12, 2018
2 parents 04dbba8 + c968525 commit 6c7e4d7
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/howler.core.js
Original file line number Diff line number Diff line change
Expand Up @@ -2217,16 +2217,24 @@
* @param {Howl} self
*/
var decodeAudioData = function(arraybuffer, self) {
// Decode the buffer into an audio source.
Howler.ctx.decodeAudioData(arraybuffer, function(buffer) {
var handle = function(buffer) {
if (buffer && self._sounds.length > 0) {
cache[self._src] = buffer;
loadSound(self, buffer);
} else {
onError();
}
}, function() {
};
var onError = function() {
self._emit('loaderror', null, 'Decoding audio data failed.');
});
};
};
// Decode the buffer into an audio source.
if(Howler.ctx.decodeAudioData.length === 1) {
Howler.ctx.decodeAudioData(arraybuffer).then(handle).catch(onError);
} else {
Howler.ctx.decodeAudioData(arraybuffer, handle, onError);
}
}

/**
* Sound is now loaded, so finish setting everything up and fire the loaded event.
Expand Down

0 comments on commit 6c7e4d7

Please sign in to comment.