Skip to content

Commit d6b11e2

Browse files
Defined seek property's setter for HTML5AudioSound class
1 parent afb8075 commit d6b11e2

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

src/sound/html5/HTML5AudioSound.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,18 @@ Object.defineProperty(HTML5AudioSound.prototype, 'seek', {
137137
else {
138138
return 0;
139139
}
140+
},
141+
set: function (value) {
142+
if (this.isPlaying || this.isPaused) {
143+
value = Math.min(Math.max(0, value), this.duration);
144+
if (this.isPlaying) {
145+
this.audio.currentTime = value;
146+
}
147+
else if (this.isPaused) {
148+
this.currentConfig.seek = value;
149+
}
150+
this.events.dispatch(new SoundValueEvent(this, 'SOUND_SEEK', value));
151+
}
140152
}
141153
});
142154
module.exports = HTML5AudioSound;

0 commit comments

Comments
 (0)