error : 0,
loop : false,
looped : false,
+ autoplay : false,
volume : 0.5,
_startTime : 0,
return;
case X.Event.SUCCESS :
+ console.log( 'WebAudio xhr success! ' + !!X_Audio_WebAudio_context.decodeAudioData );
// TODO 旧api
// https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API/Porting_webkitAudioContext_code_to_standards_based_AudioContext
if( X_Audio_WebAudio_context.decodeAudioData ){
},
_onDecodeSuccess : function( buffer ){
+ console.log( 'WebAudio decode success!' );
+
this.onDecodeSuccess && this._onDecodeComplete();
if ( !buffer ) {
this.proxy.asyncDispatch( 'loadeddata' );
this.proxy.asyncDispatch( 'canplay' );
this.proxy.asyncDispatch( 'canplaythrough' );
+
+ this.autoplay && X.Timer.once( 16, this, this.play );
+
+ console.log( 'WebAudio decoded!' );
},
_onDecodeError : function(){
+ console.log( 'WebAudio decode error!' );
this._onDecodeComplete();
this.error = 3;
this.proxy.asyncDispatch( { type : 'error', message : 'decode error' } );
play : function(){
var begin, end;
- if( !this.buffer ) return this;
+ if( !this.buffer ){
+ this.autoplay = true;
+ return;
+ };
end = X_AudioWrapper_getEndTime( this );
begin = X_AudioWrapper_getStartTime( this, end, true );