};
};
- X_Audio_WebAudioWrapper = X.EventDispatcher.inherits(
+ X_Audio_WebAudioWrapper = X_EventDispatcher[ 'inherits' ](
'X.AV.WebAudioWrapper',
X.Class.POOL_OBJECT,
{
} else
if( audio ){
// TODO 当てにしていたaudioがclose 等した場合
- audio.proxy.listenOnce( 'canplaythrough', this, this._onBufferReady );
+ audio.proxy[ 'listenOnce' ]( 'canplaythrough', this, this._onBufferReady );
} else {
this.xhr = X.Net.xhrGet( url, 'arraybuffer' )
- .listen( X_Event.PROGRESS, this )
- .listenOnce( [ X_Event.SUCCESS, X_Event.COMPLETE, X_Event.CANCELED ], this );
+ [ 'listen' ]( X_EVENT_PROGRESS, this )
+ [ 'listenOnce' ]( [ X_EVENT_SUCCESS, X_EVENT_COMPLETE, X_EVENT_CANCELED ], this );
};
},
handleEvent : function( e ){
switch( e.type ){
- case X_Event.PROGRESS :
+ case X_EVENT_PROGRESS :
e.percent ?
- this.proxy.dispatch( { type : 'progress', percent : e.percent } ) :
- this.proxy.dispatch( 'loadstart' );
+ this.proxy[ 'dispatch' ]( { type : 'progress', percent : e.percent } ) :
+ this.proxy[ 'dispatch' ]( 'loadstart' );
return;
- case X_Event.SUCCESS :
+ case X_EVENT_SUCCESS :
console.log( 'WebAudio xhr success! ' + !!X_Audio_WebAudio_context.decodeAudioData + ' t:' + typeof e.data );
// TODO 旧api
// https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API/Porting_webkitAudioContext_code_to_standards_based_AudioContext
};
break;
- case X_Event.CANCELED :
+ case X_EVENT_CANCELED :
this.error = 1;
- this.proxy.dispatch( 'aborted' );
+ this.proxy[ 'dispatch' ]( 'aborted' );
break;
- case X_Event.COMPLETE :
+ case X_EVENT_COMPLETE :
this.error = 2;
- this.proxy.asyncDispatch( { type : X_Event.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.xhr[ 'unlisten' ]( [ X_EVENT_PROGRESS, X_EVENT_SUCCESS, X_EVENT_COMPLETE, X_EVENT_CANCELED ], this );
delete this.xhr;
},
this.onDecodeSuccess && this._onDecodeComplete();
if ( !buffer ) {
- this.proxy.asyncDispatch( { type : X_Event.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' ]( 'loadedmetadata' );
+ this.proxy[ 'asyncDispatch' ]( 'loadeddata' );
+ this.proxy[ 'asyncDispatch' ]( 'canplay' );
+ this.proxy[ 'asyncDispatch' ]( 'canplaythrough' );
*/
- this.proxy.asyncDispatch( X_Event.READY );
+ this.proxy[ 'asyncDispatch' ]( X_EVENT_READY );
- this.autoplay && X.Timer.once( 16, this, this.play );
+ this.autoplay && X_Timer_once( 16, this, this.play );
console.log( 'WebAudio decoded!' );
},
console.log( 'WebAudio decode error!' );
this._onDecodeComplete();
this.error = 3;
- this.proxy.asyncDispatch( { type : X_Event.ERROR, message : 'decode error' } );
+ this.proxy[ 'asyncDispatch' ]( { type : X_EVENT_ERROR, message : 'decode error' } );
},
_onDecodeComplete : function(){
this.gainNode.gain.value = this.volume;
// おかしい、stop 前に外していても呼ばれる、、、@Firefox33.1
- // 破棄された X.Callback が呼ばれて、obj._() でエラーになる。Firefox では、onended は使わない
+ // 破棄された 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 ) );
} else {
- this._timerID && X.Timer.remove( this._timerID );
- this._timerID = X.Timer.once( end - begin, this, this._onEnded );
+ this._timerID && X_Timer_remove( this._timerID );
+ this._timerID = X_Timer_once( end - begin, this, this._onEnded );
};
if( this.source.start ){
this._startPos = begin;
this._endPosition = end;
this._startTime = X_Audio_WebAudio_context.currentTime * 1000;
- this._interval = this._interval || X.Timer.add( 1000, 0, this, this._onInterval );
+ this._interval = this._interval || X_Timer_add( 1000, 0, this, this._onInterval );
},
_onInterval : function(){
delete this._interval;
return X_Callback_UN_LISTEN;
};
- this.proxy.dispatch( X_Event.MEDIA_PLAYING );
+ this.proxy[ 'dispatch' ]( X_EVENT_MEDIA_PLAYING );
},
_onEnded : function(){
if( time < 0 ){
console.log( '> onEnd crt:' + ( X_Audio_WebAudio_context.currentTime * 1000 ) + ' startTime:' + this._startTime +
' from:' + this._startPos + ' to:' + this._endPosition );
- this._timerID = X.Timer.once( -time, this, this._onEnded );
+ this._timerID = X_Timer_once( -time, this, this._onEnded );
return;
};
};
if( this.loop ){
- if( !( this.proxy.dispatch( X_Event.MEDIA_BEFORE_LOOP ) & 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.proxy[ 'dispatch' ]( X_EVENT_MEDIA_LOOPED );
this.play();
};
} else {
this.pause();
- this.proxy.dispatch( X_Event.MEDIA_ENDED );
+ this.proxy[ 'dispatch' ]( X_EVENT_MEDIA_ENDED );
};
};
},
this.seekTime = this.state().currentTime;
- this._timerID && X.Timer.remove( this._timerID );
+ this._timerID && X_Timer_remove( this._timerID );
delete this._timerID;
delete this.playing;
//
detect : function( proxy, source, ext ){
- proxy.asyncDispatch( { type : X_Event.COMPLETE, canPlay : X_Audio_codecs[ ext ] } );
+ proxy[ 'asyncDispatch' ]( { type : X_EVENT_COMPLETE, canPlay : X_Audio_codecs[ ext ] } );
},
klass : X_Audio_WebAudioWrapper