Skip to content

Commit e13b829

Browse files
Removed redundant check in onended handler and reverted setting source to null before calling stop() on it since it does not invoke onended event handler immediately
1 parent 007a565 commit e13b829

1 file changed

Lines changed: 2 additions & 6 deletions

File tree

v3/src/sound/webaudio/WebAudioSound.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ var WebAudioSound = new Class({
110110
this.source.connect(this.muteNode);
111111
this.applyConfig();
112112
this.source.onended = function (ev) {
113-
if (this.source && ev.target === this.source) {
113+
if (ev.target === this.source) {
114114
this.stop();
115115
}
116116
}.bind(this);
@@ -123,12 +123,8 @@ var WebAudioSound = new Class({
123123
*/
124124
stopAndRemoveBufferSource: function () {
125125
if (this.source) {
126-
var source = this.source;
126+
this.source.stop();
127127
this.source = null;
128-
// Setting source to null before calling stop on it
129-
// to determine if onended event was fired when sound
130-
// ended or when it was stopped by user
131-
source.stop();
132128
}
133129
},
134130
update: function () {

0 commit comments

Comments
 (0)