Skip to content

Commit

Permalink
Merge pull request cocos#2480 from umbrellaPP/v1.9
Browse files Browse the repository at this point in the history
destroy audio element when stop
  • Loading branch information
jareguo authored Apr 16, 2018
2 parents 6c833e0 + 28779f3 commit 0344747
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cocos2d/audio/CCAudioEngine.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ var getAudioFromPath = function (path) {
var oldId = list.shift();
var oldAudio = id2audio[oldId];
oldAudio.stop();
oldAudio.destroy();
}

audio = new Audio(path);
Expand Down Expand Up @@ -365,6 +366,8 @@ var audioEngine = {
return false;
audio.off('load', audio.__callback);
audio.stop();
audio.destroy();

return true;
},

Expand All @@ -380,6 +383,7 @@ var audioEngine = {
var audio = id2audio[id];
if (audio && audio.stop) {
audio.stop();
audio.destroy();
audio.off('load', audio.__callback);
}
}
Expand Down
1 change: 1 addition & 0 deletions cocos2d/core/components/CCAudioSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ var AudioSource = cc.Class({

onDestroy: function () {
this.stop();
this.audio.destroy();
cc.audioEngine.uncache(this._clip);
},

Expand Down

0 comments on commit 0344747

Please sign in to comment.