added checks to playback control methods for WebAudioSound

This commit is contained in:
Pavle Goloskokovic 2017-11-17 17:17:06 +01:00
parent 40c4b9f6e5
commit 9098b806b2

View file

@ -71,26 +71,32 @@ var WebAudioSound = new Class({
return this; return this;
}, },
pause: function () { pause: function () {
BaseSound.prototype.pause.call(this); if (!BaseSound.prototype.pause.call(this)) {
return false;
}
this.stopAndRemoveBufferSource(); this.stopAndRemoveBufferSource();
this.pausedTime = this.manager.context.currentTime - this.startTime; this.pausedTime = this.manager.context.currentTime - this.startTime;
return this; return true;
}, },
resume: function () { resume: function () {
BaseSound.prototype.resume.call(this); if (!BaseSound.prototype.resume.call(this)) {
return false;
}
var offset = this.pausedTime; // TODO include marker start time var offset = this.pausedTime; // TODO include marker start time
var duration = this.currentConfig.duration - this.pausedTime; var duration = this.currentConfig.duration - this.pausedTime;
this.createAndStartBufferSource(offset, duration); this.createAndStartBufferSource(offset, duration);
this.startTime = this.manager.context.currentTime - this.pausedTime; this.startTime = this.manager.context.currentTime - this.pausedTime;
this.pausedTime = 0; this.pausedTime = 0;
return this; return true;
}, },
stop: function () { stop: function () {
BaseSound.prototype.stop.call(this); if (!BaseSound.prototype.stop.call(this)) {
return false;
}
this.stopAndRemoveBufferSource(); this.stopAndRemoveBufferSource();
this.startTime = 0; this.startTime = 0;
this.pausedTime = 0; this.pausedTime = 0;
return this; return true;
}, },
/** /**
* Used internally to do what the name says. * Used internally to do what the name says.