Skip to content

Commit 25a1168

Browse files
Replaced pausedTime field with config seek value
1 parent f347bcc commit 25a1168

1 file changed

Lines changed: 8 additions & 15 deletions

File tree

v3/src/sound/webaudio/WebAudioSound.js

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,6 @@ var WebAudioSound = new Class({
4747
* @property {number} startTime
4848
*/
4949
this.startTime = 0;
50-
/**
51-
* Relative time when sound was paused.
52-
* Corresponds to the seek value at the time when pause() method was called on this sound.
53-
*
54-
* @private
55-
* @property {number} pausedTime
56-
*/
57-
this.pausedTime = 0;
5850
/**
5951
* An array where we keep track of all rate updates during playback.
6052
*
@@ -87,7 +79,7 @@ var WebAudioSound = new Class({
8779
var duration = this.duration - seek;
8880
this.createAndStartBufferSource(offset, duration);
8981
this.startTime = this.manager.context.currentTime - seek;
90-
this.pausedTime = 0;
82+
this.currentConfig.seek = 0;
9183
return this;
9284
},
9385
pause: function () {
@@ -96,7 +88,7 @@ var WebAudioSound = new Class({
9688
}
9789
// \/\/\/ isPlaying = false, isPaused = true \/\/\/
9890
this.stopAndRemoveBufferSource();
99-
this.pausedTime = this.seek;
91+
this.currentConfig.seek = this.seek; // Equivalent to setting paused time
10092
return true;
10193
},
10294
resume: function () {
@@ -105,11 +97,12 @@ var WebAudioSound = new Class({
10597
}
10698
// \/\/\/ isPlaying = true, isPaused = false \/\/\/
10799
// TODO take in account playback rate
108-
var offset = (this.currentMarker ? this.currentMarker.start : 0) + this.pausedTime;
109-
var duration = this.duration - this.pausedTime;
100+
var seek = this.currentConfig.seek;
101+
var offset = (this.currentMarker ? this.currentMarker.start : 0) + seek;
102+
var duration = this.duration - seek;
110103
this.createAndStartBufferSource(offset, duration);
111-
this.startTime = this.manager.context.currentTime - this.pausedTime;
112-
this.pausedTime = 0;
104+
this.startTime = this.manager.context.currentTime - seek;
105+
this.currentConfig.seek = 0;
113106
return true;
114107
},
115108
stop: function () {
@@ -119,7 +112,7 @@ var WebAudioSound = new Class({
119112
// \/\/\/ isPlaying = false, isPaused = false \/\/\/
120113
this.stopAndRemoveBufferSource();
121114
this.startTime = 0;
122-
this.pausedTime = 0;
115+
this.currentConfig.seek = 0;
123116
return true;
124117
},
125118
/**

0 commit comments

Comments
 (0)