OSDN Git Service

Version 0.6.182, fix X.UA.
[pettanr/clientJs.git] / 0.6.x / js / 07_audio / 01_XWebAudio.js
index 522443d..966f667 100644 (file)
@@ -78,14 +78,16 @@ if( X_Audio_constructor ){
 };
 
 
-var X_WebAudio_context = !X_UA[ 'iPhone_4s' ]  && !X_UA[ 'iPad_2Mini1' ]  && !X_UA[ 'iPod_4' ]  &&
-                                                               // TODO なんで fennec を禁止?
-                                                               !( X_UA[ 'Gecko' ] && X_UA[ 'Android' ] ) &&
+var X_WebAudio_context      =  // 4s 以下ではない iPad 2G または iPad mini 1G 以下ではない, iPod touch 4G 以下ではない
+                                                               !X_UA[ 'iPhone_4s' ]  && !X_UA[ 'iPad_2Mini1' ]  && !X_UA[ 'iPod_4' ]  &&
+                                                               // Android2 + Gecko で WebAudio が極めて不安定
+                                                               !( X_UA[ 'Fennec' ] && X_UA[ 'Android' ] < 3 ) &&
                                                                // 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;
@@ -217,7 +219,7 @@ if( X_WebAudio_context ){
             gainNode        : null,
             _onended        : null,
             
-                       'Constructor' : function( target, url, option ){                                
+                       'Constructor' : function( disatcher, url, option ){                             
                                var i = 0,
                                        l = X_WebAudio_BUFFER_LIST.length,
                                        loader;
@@ -245,8 +247,7 @@ if( X_WebAudio_context ){
                                        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 );
@@ -280,7 +281,7 @@ if( X_WebAudio_context ){
                        if ( !buffer ) {
                                this.error = loader.errorState;
                                
-                           this.target[ 'dispatch' ]({
+                           this.disatcher[ 'dispatch' ]({
                                                                type    : X_EVENT_ERROR,
                                                                error   : loader.errorState,
                                                                message : loader.errorState === 1 ?
@@ -294,7 +295,7 @@ if( X_WebAudio_context ){
                        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' );
                        
@@ -305,6 +306,8 @@ if( X_WebAudio_context ){
                        actualPlay : function(){
                                var begin, end;
                                
+                               console.log( '[WebAudio] play abuf:' + !!this.audioBuffe );
+                               
                    if( !this.audioBuffer ){
                        this.autoplay = true;
                        return;
@@ -361,7 +364,7 @@ if( X_WebAudio_context ){
                                                delete this._interval;
                                                return X_CALLBACK_UN_LISTEN;
                                        };
-                                       this.target[ 'dispatch' ]( X_EVENT_MEDIA_PLAYING );
+                                       this.disatcher[ 'dispatch' ]( X_EVENT_MEDIA_PLAYING );
                                },
                                                
                                _onEnded : function(){
@@ -384,14 +387,14 @@ if( X_WebAudio_context ){
                                };
                                
                                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 );
                                };
                            };
                                },