OSDN Git Service

Version 0.6.183, refactoring X.HTMLAudio.
[pettanr/clientJs.git] / 0.6.x / js / 07_audio / 01_XWebAudio.js
index c9fa1ed..47026ef 100644 (file)
@@ -78,9 +78,10 @@ if( X_Audio_constructor ){
 };
 
 
-var X_WebAudio_context      = !X_UA[ 'iPhone_4s' ]  && !X_UA[ 'iPad_2Mini1' ]  && !X_UA[ 'iPod_4' ]  &&
+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[ 'Fennec' ] && X_UA[ 'Android' ] < 3 ) &&
                                                                // Firefox40.0.5 + Windows8 で音声が途中から鳴らなくなる
                                                                // Firefox41.0.1 + Windows8 で音声が途中から鳴らなくなる
                                                                !( 40 <= X_UA[ 'Gecko' ] && X_UA[ 'Gecko' ] < 42 && X_UA[ 'Windows' ] ) &&
@@ -298,20 +299,28 @@ if( X_WebAudio_context ){
                        
                        console.log( 'WebAudio buffer ready' );
                        
-                       this.autoplay && X_Timer_once( 16, this, this.play );
+                       this.autoplay && !X_WebAudio_need1stTouch && X_Timer_once( 16, this, this.actualPlay );
                                        
                                },
                        
                        actualPlay : function(){
-                               var begin, end;
+                               var e, begin, end;
                                
-                               console.log( '[WebAudio] play abuf:' + !!this.audioBuffe );
+                               console.log( '[WebAudio] play abuf:' + !!this.audioBuffer );
                                
                    if( !this.audioBuffer ){
                        this.autoplay = true;
                        return;
                    };
                                
+                               if( X_WebAudio_need1stTouch ){
+                                       e = X_EventDispatcher_CURRENT_EVENTS[ X_EventDispatcher_CURRENT_EVENTS.length - 1 ];
+                                       if( !e || !e[ 'pointerType' ] ){
+                                               alert( 'タッチイベント以外での play! ' + ( e ? e.type : '' ) );
+                                               return;
+                                       };
+                               };
+                               
                                end   = X_Audio_getEndTime( this );
                                begin = X_Audio_getStartTime( this, end, true );