change to trigger the finishCallback after the audio ended (#3167)

This commit is contained in:
Knox
2018-08-30 17:59:01 +08:00
committed by pandamicro
parent c0509efb9a
commit 1407fb9eb8
+8 -5
View File
@@ -62,10 +62,6 @@ let getAudioFromPath = function (path) {
var audio = _audioPool.pop() || new Audio();
var callback = function () {
if (audio._finishCallback) {
audio._finishCallback();
}
var audioInList = getAudioFromId(this.id);
if (audioInList) {
delete _id2audio[this.id];
@@ -74,7 +70,14 @@ let getAudioFromPath = function (path) {
}
recycleAudio(this);
};
audio.on('ended', callback, audio);
audio.on('ended', function () {
if (audio._finishCallback) {
audio._finishCallback();
}
callback();
}, audio);
audio.on('stop', callback, audio);
audio.id = id;
_id2audio[id] = audio;