loopEndTime : -1,
seekTime : -1,
duration : 0,
-
+
playing : false,
error : 0,
loop : false,
Constructor : function( proxy, url, option ){
var audio = X_Audio_WebAudio_getBuffer( url );
- this.url = url;
- this.closed = false;
this.proxy = proxy;
+ this.url = url;
X_AudioWrapper_updateStates( this, option );
case X.Event.COMPLETE :
this.error = 2;
- this.proxy.asyncDispatch( { type : 'error', message : 'xhr error' } );
+ this.proxy.asyncDispatch( { type : X.Event.ERROR, message : 'xhr error' } );
break;
};
this.xhr.unlisten( [ X.Event.PROGRESS, X.Event.SUCCESS, X.Event.COMPLETE, X.Event.CANCELED ], this );
this.onDecodeSuccess && this._onDecodeComplete();
if ( !buffer ) {
- this.proxy.asyncDispatch( { type : 'error', message : 'buffer is ' + buffer } );
+ this.proxy.asyncDispatch( { type : X.Event.ERROR, message : 'buffer is ' + buffer } );
return;
};
this.buffer = buffer;
this.duration = buffer.duration * 1000;
-
+ /*
this.proxy.asyncDispatch( 'loadedmetadata' );
this.proxy.asyncDispatch( 'loadeddata' );
this.proxy.asyncDispatch( 'canplay' );
this.proxy.asyncDispatch( 'canplaythrough' );
+ */
+ this.proxy.asyncDispatch( X.Event.READY );
this.autoplay && X.Timer.once( 16, this, this.play );
console.log( 'WebAudio decode error!' );
this._onDecodeComplete();
this.error = 3;
- this.proxy.asyncDispatch( { type : 'error', message : 'decode error' } );
+ this.proxy.asyncDispatch( { type : X.Event.ERROR, message : 'decode error' } );
},
_onDecodeComplete : function(){
delete this._interval;
return X_Callback_UN_LISTEN;
};
- this.proxy.dispatch( 'timeupdate' );
+ this.proxy.dispatch( X.Event.MEDIA_PLAYING );
},
_onEnded : function(){
};
if( this.loop ){
- if( !( this.proxy.dispatch( 'looped' ) & X.Callback.PREVENT_DEFAULT ) ){
+ if( !( this.proxy.dispatch( X.Event.MEDIA_BEFORE_LOOP ) & X.Callback.PREVENT_DEFAULT ) ){
this.looped = true;
+ this.proxy.dispatch( X.Event.MEDIA_LOOPED );
this.play();
- };
+ };
} else {
this.pause();
- this.proxy.dispatch( 'ended' );
+ this.proxy.dispatch( X.Event.MEDIA_ENDED );
};
};
},
}
);
-
+
+
X_Audio_BACKENDS.push(
{
backendName : 'Web Audio',
//
detect : function( proxy, source, ext ){
- proxy.asyncDispatch( X_Audio_codecs[ ext ] ? 'support' : 'nosupport' );
+ proxy.asyncDispatch( X_Audio_codecs[ ext ] ? X_Audio_CAN_PLAY : X_Audio_NOT_PLAY );
},
klass : X_Audio_WebAudioWrapper
}
);
-
};