Skip to content

Commit 44ce0ed

Browse files
Moved the same logic for calculating offset duration and startTime into createAndStartBufferSource method
1 parent 25a1168 commit 44ce0ed

1 file changed

Lines changed: 8 additions & 16 deletions

File tree

v3/src/sound/webaudio/WebAudioSound.js

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,7 @@ var WebAudioSound = new Class({
7474
}
7575
// \/\/\/ isPlaying = true, isPaused = false \/\/\/
7676
this.stopAndRemoveBufferSource();
77-
var seek = this.currentConfig.seek;
78-
var offset = (this.currentMarker ? this.currentMarker.start : 0) + seek;
79-
var duration = this.duration - seek;
80-
this.createAndStartBufferSource(offset, duration);
81-
this.startTime = this.manager.context.currentTime - seek;
82-
this.currentConfig.seek = 0;
77+
this.createAndStartBufferSource();
8378
return this;
8479
},
8580
pause: function () {
@@ -96,13 +91,7 @@ var WebAudioSound = new Class({
9691
return false;
9792
}
9893
// \/\/\/ isPlaying = true, isPaused = false \/\/\/
99-
// TODO take in account playback rate
100-
var seek = this.currentConfig.seek;
101-
var offset = (this.currentMarker ? this.currentMarker.start : 0) + seek;
102-
var duration = this.duration - seek;
103-
this.createAndStartBufferSource(offset, duration);
104-
this.startTime = this.manager.context.currentTime - seek;
105-
this.currentConfig.seek = 0;
94+
this.createAndStartBufferSource();
10695
return true;
10796
},
10897
stop: function () {
@@ -119,11 +108,14 @@ var WebAudioSound = new Class({
119108
* Used internally to do what the name says.
120109
*
121110
* @private
122-
* @param {number} offset
123-
* @param {number} duration
124111
*/
125112
// TODO add when param
126-
createAndStartBufferSource: function (offset, duration) {
113+
createAndStartBufferSource: function () {
114+
var seek = this.currentConfig.seek;
115+
var offset = (this.currentMarker ? this.currentMarker.start : 0) + seek;
116+
var duration = this.duration - seek;
117+
this.startTime = this.manager.context.currentTime - seek;
118+
this.currentConfig.seek = 0;
127119
this.source = this.manager.context.createBufferSource();
128120
this.source.buffer = this.audioBuffer;
129121
this.source.connect(this.muteNode);

0 commit comments

Comments
 (0)