this.shouldBePlaying = 0;
this.startTime = 0;
this.nextStartTime = 0;
- this.load();
}
Sound.prototype = {
playInternal: function() {
this.gainNode = Sound.audioContext.createGainNode();
- this.gainNode.gain.value = this._volume;
+ this.gainNode.gain.value = this._muted ? 0 : this._volume;
this.gainNode.connect(Sound.audioContext.destination);
this.node = Sound.audioContext.createBufferSource();
},
onended: function() {
+ if (this._loop) {
+ this.stopInternal();
+ this.setCurrentTime(0);
+ this.playInternal();
+ return;
+ }
+
this._ended = true;
this.nextStartTime = 0;
this.stopInternal();
setSrc: function(src) {
this._src = src;
- this.load();
+ if (this._autoplay && this._src != null)
+ this.load();
},
getCurrentSrc: function() {
if (this.gainNode)
this.gainNode.gain.value = this._muted ? 0 : this._volume;
},
+
+ getAutoplay: function() {
+ return this._autoplay;
+ },
+
+ setAutoplay: function(autoplay) {
+ if (this._autoplay == autoplay)
+ return;
+
+ this._autoplay = autoplay;
+ if (this._autoplay && this._src != null)
+ this.load();
+ },
+
+ getLoop: function() {
+ return this._loop;
+ },
+
+ setLoop: function(loop) {
+ this._loop = loop;
+ },
};
Object.defineProperty(Sound.prototype, 'src', {