Skip to content

Commit afb8075

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

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

src/sound/html5/HTML5AudioSound.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,4 +120,23 @@ Object.defineProperty(HTML5AudioSound.prototype, 'volume', {
120120
this.events.dispatch(new SoundValueEvent(this, 'SOUND_VOLUME', value));
121121
}
122122
});
123+
/**
124+
* Current position of playing sound.
125+
*
126+
* @name Phaser.Sound.HTML5AudioSound#seek
127+
* @property {number} seek
128+
*/
129+
Object.defineProperty(HTML5AudioSound.prototype, 'seek', {
130+
get: function () {
131+
if (this.isPlaying) {
132+
return this.audio.currentTime;
133+
}
134+
else if (this.isPaused) {
135+
return this.currentConfig.seek;
136+
}
137+
else {
138+
return 0;
139+
}
140+
}
141+
});
123142
module.exports = HTML5AudioSound;

0 commit comments

Comments
 (0)