!( X_UA[ 'Gecko' ] && X_UA[ 'Android' ] ) &&
( window.AudioContext || window.webkitAudioContext ),
X_Audio_BUFFER_LIST = [],
- X_Audio_WebAudioWrapper;
+ X_Audio_WebAudioWrapper,
+ X_Audio_BufferLoader;
/*
* iPhone 4s 以下、iPad2以下、iPad mini 1以下, iPod touch 4G 以下は不可
} else
if( X_Audio_WebAudio_context.decodeAudioData ){
X_Audio_WebAudio_context.decodeAudioData( e.response,
- this.onDecodeSuccess = X_Callback_create( this, this._onDecodeSuccess ),
- this.onDecodeError = X_Callback_create( this, this._onDecodeError ) );
+ this.onDecodeSuccess = X_Closure_create( this, this._onDecodeSuccess ),
+ this.onDecodeError = X_Closure_create( this, this._onDecodeError ) );
} else {
this._onDecodeSuccess( X_Audio_WebAudio_context.createBuffer( e.response, false ) );
};
},
_onDecodeComplete : function(){
- X_Callback_correct( this.onDecodeSuccess );
+ X_Closure_correct( this.onDecodeSuccess );
delete this.onDecodeSuccess;
- X_Callback_correct( this.onDecodeError );
+ X_Closure_correct( this.onDecodeError );
delete this.onDecodeError;
},
this.setState( option );
- this[ 'listenOnce' ]( X_EVENT_KILL_INSTANCE, X_WebAudio_handleEvent );
+ this[ 'listenOnce' ]( X_EVENT_KILL_INSTANCE, this.onKill );
if( loader.buffer || loader.error ){
this._onLoadBufferComplete();
loader[ 'listenOnce' ]( X_EVENT_COMPLETE, this, this._onLoadBufferComplete );
};
},
+
+ onKill : function(){
+ this.loader[ 'unlisten' ]( X_EVENT_COMPLETE, this, this._onLoadBufferComplete )
+ .unregister( this );
+
+ delete this.buffer;
+
+ this.playing && this.actualPause();
+ this.source && this._sourceDispose();
+
+ this._onended && X_Closure_correct( this._onended );
+
+ this.gainNode && this.gainNode.disconnect();
+ },
_onLoadBufferComplete : function( e ){
var loader = this.loader,
buffer = loader.buffer;
// 破棄された X.Callback が呼ばれて、obj.proxy() でエラーになる。Firefox では、onended は使わない
if( false && this.source.onended !== undefined ){
//console.log( '> use onended' );
- this.source.onended = this._onended || ( this._onended = X_Callback_create( this, this._onEnded ) );
+ this.source.onended = this._onended || ( this._onended = X_Closure_create( this, this._onEnded ) );
} else {
this._timerID && X_Timer_remove( this._timerID );
this._timerID = X_Timer_once( end - begin, this, this._onEnded );
_onInterval : function(){
if( !this.playing ){
delete this._interval;
- return X_Callback_UN_LISTEN;
+ return X_CALLBACK_UN_LISTEN;
};
this.target[ 'dispatch' ]( X_EVENT_MEDIA_PLAYING );
},
};
if( this.autoLoop ){
- if( !( this.target[ 'dispatch' ]( X_EVENT_MEDIA_BEFORE_LOOP ) & X_Callback_PREVENT_DEFAULT ) ){
+ if( !( this.target[ 'dispatch' ]( X_EVENT_MEDIA_BEFORE_LOOP ) & X_CALLBACK_PREVENT_DEFAULT ) ){
this.looped = true;
this.target[ 'dispatch' ]( X_EVENT_MEDIA_LOOPED );
this.actualPlay();
}
);
- function X_WebAudio_handleEvent( e ){
- switch( e.type ){
-
- case X_EVENT_KILL_INSTANCE :
- this.loader[ 'unlisten' ]( X_EVENT_COMPLETE, this, this._onLoadBufferComplete )
- .unregister( this );
-
- delete this.buffer;
-
- this.playing && this.actualPause();
- this.source && this._sourceDispose();
-
- this._onended && X_Callback_correct( this._onended );
-
- this.gainNode && this.gainNode.disconnect();
- break;
- };
- };
-
/*
* http://qiita.com/sou/items/5688d4e7d3a37b4e2ff1
* L-01F 等の一部端末で Web Audio API の再生結果に特定条件下でノイズが混ざることがある。
{
backendName : 'Web Audio',
+ canPlay : {}, // TODO HTMLAudio と同じ
+
//
detect : function( proxy, source, ext ){
proxy[ 'asyncDispatch' ]( { type : X_EVENT_COMPLETE, canPlay : X_Audio_codecs[ ext ] } );