};
-var X_WebAudio_context = !X_UA[ 'iPhone_4s' ] && !X_UA[ 'iPad_2Mini1' ] && !X_UA[ 'iPod_4' ] &&
- // TODO なんで fennec を禁止?
+var X_WebAudio_context = !X_UA[ 'iPhone_4s' ] && !X_UA[ 'iPad_2Mini1' ] && !X_UA[ 'iPod_4' ] &&
+ // Android2 + Gecko で WebAudio が極めて不安定
!( X_UA[ 'Gecko' ] && X_UA[ 'Android' ] ) &&
// Firefox40.0.5 + Windows8 で音声が途中から鳴らなくなる
// Firefox41.0.1 + Windows8 で音声が途中から鳴らなくなる
!( 40 <= X_UA[ 'Gecko' ] && X_UA[ 'Gecko' ] < 42 && X_UA[ 'Windows' ] ) &&
( window[ 'AudioContext' ] || window[ 'webkitAudioContext' ] ),
- X_WebAudio_BUFFER_LIST = [],
+ X_WebAudio_BUFFER_LIST = [],
+ X_WebAudio_need1stTouch = X_UA[ 'iOS' ],
X_WebAudio,
X_WebAudio_BufferLoader,
X_WebAudio_fpsFix;
gainNode : null,
_onended : null,
- 'Constructor' : function( target, url, option ){
+ 'Constructor' : function( disatcher, url, option ){
var i = 0,
l = X_WebAudio_BUFFER_LIST.length,
loader;
this.loader = loader = X_WebAudio_BufferLoader( this, url );
};
- this.target = target || this;
-
+ this.disatcher = disatcher || this;
this.setState( option );
this[ 'listenOnce' ]( X_EVENT_KILL_INSTANCE, this.onKill );
if ( !buffer ) {
this.error = loader.errorState;
- this.target[ 'dispatch' ]({
+ this.disatcher[ 'dispatch' ]({
type : X_EVENT_ERROR,
error : loader.errorState,
message : loader.errorState === 1 ?
this.audioBuffer = buffer;
this.duration = buffer.duration * 1000;
- this.target[ 'asyncDispatch' ]( X_EVENT_READY );
+ this.disatcher[ 'asyncDispatch' ]( X_EVENT_READY );
console.log( 'WebAudio buffer ready' );
actualPlay : function(){
var begin, end;
+ console.log( '[WebAudio] play abuf:' + !!this.audioBuffe );
+
if( !this.audioBuffer ){
this.autoplay = true;
return;
delete this._interval;
return X_CALLBACK_UN_LISTEN;
};
- this.target[ 'dispatch' ]( X_EVENT_MEDIA_PLAYING );
+ this.disatcher[ 'dispatch' ]( X_EVENT_MEDIA_PLAYING );
},
_onEnded : function(){
};
if( this.autoLoop ){
- if( !( this.target[ 'dispatch' ]( X_EVENT_MEDIA_BEFORE_LOOP ) & X_CALLBACK_PREVENT_DEFAULT ) ){
+ if( !( this.disatcher[ 'dispatch' ]( X_EVENT_MEDIA_BEFORE_LOOP ) & X_CALLBACK_PREVENT_DEFAULT ) ){
this.looped = true;
- this.target[ 'dispatch' ]( X_EVENT_MEDIA_LOOPED );
+ this.disatcher[ 'dispatch' ]( X_EVENT_MEDIA_LOOPED );
this.actualPlay();
};
} else {
this.actualPause();
- this.target[ 'dispatch' ]( X_EVENT_MEDIA_ENDED );
+ this.disatcher[ 'dispatch' ]( X_EVENT_MEDIA_ENDED );
};
};
},