Skip to content

Commit e6f1774

Browse files
handling source buffer on method calls for WebAudioSound
1 parent 7b90fc7 commit e6f1774

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

v3/src/sound/webaudio/WebAudioSound.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,18 +65,25 @@ var WebAudioSound = new Class({
6565
this.source.buffer = this.audioBuffer;
6666
this.source.connect(this.muteNode);
6767
this.applyConfig();
68-
this.source.start();
68+
this.source.start(0, 0, this.currentConfig.duration);
6969
this.startTime = this.manager.context.currentTime;
7070
this.pausedTime = 0;
7171
return this;
7272
},
7373
pause: function () {
7474
BaseSound.prototype.pause.call(this);
75+
this.source.stop();
76+
this.source = null;
7577
this.pausedTime = this.manager.context.currentTime - this.startTime;
7678
return this;
7779
},
7880
resume: function () {
7981
BaseSound.prototype.resume.call(this);
82+
this.source = this.manager.context.createBufferSource();
83+
this.source.buffer = this.audioBuffer;
84+
this.source.connect(this.muteNode);
85+
this.applyConfig();
86+
this.source.start(0, this.pausedTime, this.currentConfig.duration - this.pausedTime);
8087
this.startTime = this.manager.context.currentTime - this.pausedTime;
8188
this.pausedTime = 0;
8289
return this;

0 commit comments

Comments
 (0)