Skip to content

Commit bf77380

Browse files
Added onBlur method to be used when sound pauses on loose of focus
Saving sound state and stopping it
1 parent a6ec0af commit bf77380

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

src/sound/html5/HTML5AudioSound.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,17 @@ var HTML5AudioSound = new Class({
169169
reset: function () {
170170
BaseSound.prototype.stop.call(this);
171171
},
172+
onBlur: function () {
173+
this.currentConfig.seek = this.audio.currentTime -
174+
(this.currentMarker ? this.currentMarker.start : 0);
175+
if (this.startTime > 0) {
176+
this.currentConfig.delay = (this.startTime - window.performance.now()) / 1000;
177+
}
178+
else {
179+
this.currentConfig.delay = 0;
180+
}
181+
this.stopAndReleaseAudioTag();
182+
},
172183
update: function (time, delta) {
173184
// TODO include play method call delay
174185
if (this.isPlaying) {

0 commit comments

Comments
 (0)