+ resourceFetchingProgressed: function() {
+ this.dispatchEventAsync(new CustomEvent('progress'));
+ },
+
+ resourceFetchingSucceeded: function() {
+ if (!this.ajax.response)
+ return;
+
+ this.setNetworkState(this.NETWORK.IDLE);
+ this.dispatchEventAsync(new CustomEvent('suspend'));
+ this.setReadyState(this.READY.FUTURE_DATA);
+
+ try {
+ Sound.audioContext.decodeAudioData(
+ this.ajax.response,
+ this.resourceDecodingSucceeded.bind(this),
+ this.resourceDecodingFailed.bind(this)
+ );
+ } catch(exception) {
+ console.log(exception);
+ }
+ },
+
+ resourceFetchingFailed: function() {
+ this.error = { code: MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED };
+ this.setNetworkState(this.NETWORK.NO_SOURCE);
+ this.dispatchEventAsync(new CustomEvent('error'));
+ this.delayingTheLoadEvent = false;
+ },
+
+ resourceDecodingSucceeded: function(buffer) {
+ this.buffer = buffer;
+
+ this.setCurrentTime(0);
+ this.dispatchEventAsync(new CustomEvent('durationchange'));
+ this.setReadyState(this.READY.METADATA);
+
+ if (this.autoplaying && this._paused && this._autoplay)
+ this.play();
+ this.dispatchEventAsync(new CustomEvent('canplaythrough'));
+ },
+
+ resourceDecodingFailed: function(error) {
+ this._error = { code: HTMLMediaElement.MEDIA_ERR_DECODE };
+ this.dispatchEventAsync(new CustomEvent('error'));
+ if (this._readyState === this.READY.NOTHING) {
+ this.setNetworkState(this.NETWORK.EMPTY);
+ this.dispatchEventAsync('emptied');
+ } else
+ this.setNetworkState(this.NETWORK.IDLE);
+ },
+