OSDN Git Service

Version 0.6.216, bug fixes X.WebAudio.
authoritozyun <itozyun@user.sourceforge.jp>
Tue, 29 Mar 2016 22:33:27 +0000 (07:33 +0900)
committeritozyun <itozyun@user.sourceforge.jp>
Tue, 29 Mar 2016 22:33:27 +0000 (07:33 +0900)
0.6.x/js/01_core/13_XClass.js
0.6.x/js/02_dom/10_XNodeAnime.js
0.6.x/js/05_util/04_XXML.js
0.6.x/js/06_net/04_XNetImage.js
0.6.x/js/07_audio/01_XWebAudio.js
0.6.x/js/07_audio/02_XHTMLAudio.js

index 24ed3eb..2b93669 100644 (file)
@@ -25,7 +25,10 @@ var
        X_Class_traits             = null,\r
        X_Class_useObjectCreate    = false, // !!Object.create, http://jsperf.com/prototype-vs-object-create-perf\r
        // Opera Mobile 12.10 Android11 IS01 でクラスのメンバが欠落する問題に遭遇。__proto__ を辞めると動作,,,\r
-       X_Class_use_proto_         = !X_UA[ 'OperaMobile' ] && !X_UA[ 'OperaTablet' ] && !!X_emptyFunction.prototype.__proto__,\r
+       X_Class_use_proto_         = !X_UA[ 'OperaMobile' ] && !X_UA[ 'OperaTablet' ] &&\r
+                                                               // Android で原因不明のエラーに遭遇しているのは、この辺りが怪しい... 2016.3.9\r
+                                                                !X_UA[ 'AOSP' ] && !X_UA[ 'ChromeWV' ] &&\r
+                                                                       !!X_emptyFunction.prototype.__proto__,\r
        X_Class_constructorFix     = X_UA[ 'AOSP' ] < 3 || X_UA[ 'iOS' ] < 5,\r
        X_Class_SEAL_KILLING       = [],\r
 \r
index 2c877f2..4320ec1 100644 (file)
@@ -202,6 +202,9 @@ function X_Node_animate( obj ){
                        obj.phase      = 4; // 強制停止(GPU転送予約)または値のみ更新\r
                        obj.releaseNow = false; // TODO folower がいるため GPU 転送できないケースあり\r
                        X_NodeAnime_needsDetection = true;\r
+               } else {\r
+                       obj.phase = 1;\r
+                       X_NodeAnime_needsDetection = true;\r
                };\r
                \r
                if( !X_NodeAnime_reserved ){\r
index 7930433..fded5b5 100644 (file)
@@ -85,6 +85,7 @@ function XMLWrapper_get( index ){
 \r
 /**\r
  * セレクターにヒットした要素の内容を指定されたデータ型で返す。複数要素にヒットした場合、0番目の要素の内容を使用する。\r
+ * '' をセレクタとして渡すとノードの値を返す\r
  * @alias X.XML.prototype.val\r
  * @param {string} queryString XML セレクター文字列\r
  * @param {string} type 'number','int','boolean','string'\r
index e93c46b..3d98df3 100644 (file)
@@ -6,7 +6,7 @@
  *  AUTHOR: uupaa.js@gmail.com\r
  * \r
  */\r
-var X_ImgLoader_image     = window[ 'Image' ] && new Image(),\r
+var X_ImgLoader_image     = window[ 'Image' ] && new Image(), // ここで無用なアクセスをIEがしているかも\r
        // IE では厳密には HTMLImageElement ではなく、appendChild してもサイズが取れず、removeChild に失敗する\r
        X_ImgLoader_isElement = !( X_UA[ 'IE' ] < 9 ) && X_Type_isHTMLElement( X_ImgLoader_image ),\r
        // http://uupaa.hatenablog.com/entry/2013/12/17/171809\r
index 98eee1b..67011bb 100644 (file)
@@ -90,7 +90,7 @@ var X_WebAudio_context      = // 4s 以下ではない iPad 2G または iPad mi
                                                                //!X_UA[ 'Blink' ] &&
                                                                // Firefox40.0.5 + Windows8 で音声が途中から鳴らなくなる
                                                                // Firefox41.0.1 + Windows8 で音声が途中から鳴らなくなる
-                                                               !( 40 <= X_UA[ 'Gecko' ] && X_UA[ 'Gecko' ] < 45 && X_UA[ 'Windows' ] ) &&
+                                                               !( 40 <= X_UA[ 'Gecko' ] && X_UA[ 'Gecko' ] < 46 && X_UA[ 'Windows' ] ) &&
                                                                ( window[ 'AudioContext' ] || window[ 'webkitAudioContext' ] ),
        X_WebAudio_BUFFER_LIST  = [],
        X_WebAudio_need1stTouch = X_UA[ 'iOS' ],
@@ -229,7 +229,7 @@ if( X_WebAudio_context ){
                audioBuffer     : null,
                bufferSource    : null,
             gainNode        : null,
-            _onended        : null,
+            //_onended        : null,
             
                        'Constructor' : function( disatcher, url, option ){                             
                                var i = 0,
@@ -280,7 +280,7 @@ if( X_WebAudio_context ){
                                this.playing      && this.actualPause();
                    this.bufferSource && this._sourceDispose();
        
-                   this._onended     && X_Closure_correct( this._onended );    
+                   //this._onended     && X_Closure_correct( this._onended );  
        
                    this.gainNode     && this.gainNode.disconnect();
                        },
@@ -334,17 +334,24 @@ if( X_WebAudio_context ){
                                end   = X_Audio_getEndTime( this );
                                begin = X_Audio_getStartTime( this, end, true );
                                
-                               console.log( '[WebAudio] play ' + begin + ' -> ' + end );
+                               console.log( '[WebAudio] play ' + begin + ' -> ' + end + ' loop: ' + this.autoLoop + ' :' + this.loopStartTime + ' -> ' + this.loopEndTime );
                                
                                if( this.bufferSource ) this._sourceDispose();
                                if( !this.gainNode ){
                                        this.gainNode = X_WebAudio_context[ 'createGain' ] ? X_WebAudio_context[ 'createGain' ]() : X_WebAudio_context[ 'createGainNode' ]();
-                       this.gainNode[ 'connect' ]( X_WebAudio_context[ 'destination' ] );
+                                       this.gainNode[ 'connect' ]( X_WebAudio_context[ 'destination' ] );
                                };
+                               
                    this.bufferSource        = X_WebAudio_context[ 'createBufferSource' ]();
                    this.bufferSource.buffer = this.audioBuffer;
-                   this.bufferSource[ 'connect' ]( this.gainNode );
                    
+                   /* win8.1 Firefox45, win8.1 Chrome48 で動かなくなる...
+                   if( this.bufferSource[ 'loop' ] = this.autoLoop ){
+                       this.bufferSource[ 'loopStart' ] = 0 <= this.loopStartTime ? this.loopStartTime / 1000 : begin / 1000;
+                       this.bufferSource[ 'loopEnd'   ] = 0 <= this.loopEndTime   ? this.loopEndTime   / 1000 : end   / 1000;
+                   }; */
+                   
+                   this.bufferSource[ 'connect' ]( this.gainNode );
                    this.gainNode[ 'gain' ].value = this.gain;
                    
                    // おかしい、stop 前に外していても呼ばれる、、、@Firefox33.1
@@ -359,17 +366,19 @@ if( X_WebAudio_context ){
                 //};
        
                    if( this.bufferSource.start ){
-                       this.bufferSource.start( 0, begin / 1000, end / 1000 );
+                       this.bufferSource.start( 0, begin / 1000, ( end - begin ) / 1000 );
+                   } else
+                   if( this.bufferSource[ 'noteOn' ] ){
+                       this.bufferSource[ 'noteOn' ]( 0, begin / 1000, ( end - begin ) / 1000 );
                    } else {
-                       this.bufferSource[ 'noteGrainOn' ]( 0, begin / 1000, end / 1000 );
+                       this.bufferSource[ 'noteGrainOn' ]( 0, begin / 1000, ( end - begin ) / 1000 );
                    };
                    
                    this.playing      = true;
                    this._startPos    = begin;
                    this._endPosition = end;
                    this._startTime   = X_WebAudio_context.currentTime * 1000;
-                   // this._interval    = this._interval || X_Timer_add( 1000, 0, this, this._onInterval );
-                   this._interval    = this._interval || X_Timer_add( 100, 0, this, this._onEnded );
+                   this._interval    = this._interval || X_Timer_add( 100, 0, this, this._onInterval );
                        },
                        
                                _sourceDispose : function(){
@@ -387,25 +396,18 @@ if( X_WebAudio_context ){
                                        this.disatcher[ 'dispatch' ]( X_EVENT_MEDIA_PLAYING );
                                }, */
                                        
-                               _onEnded : function(){
+                               _onInterval : function(){
                                        var time;
-                                       //delete this._timerID;
                                        
                            if( this.playing ){
+                               // TODO 再生中に終了時間だけ変えた場合!
                                time = X_WebAudio_context.currentTime * 1000 - this._startTime - this._endPosition + this._startPos | 0;
                                //console.log( '> onEnd ' + ( this.playing && ( X_WebAudio_context.currentTime * 1000 - this._startTime ) ) + ' < ' + ( this._endPosition - this._startPos ) );
-                               if( this._onended ){
-                                       // Firefox 用の対策,,,
-                                       if( time < 0 ) return;
-                               } else {
-                                       if( time < 0 ){
-                                               this.disatcher[ 'dispatch' ]( X_EVENT_MEDIA_PLAYING );
-                                               //console.log( '> onEnd crt:' + ( X_WebAudio_context.currentTime * 1000 ) + ' startTime:' + this._startTime +
-                                               //      ' from:' + this._startPos + ' to:' + this._endPosition );
-                                               // this._timerID = X_Timer_once( -time, this, this._onEnded );
-                                               return;
-                                       };
-                               };
+
+                               if( time < 0 ){
+                                       this.disatcher[ 'dispatch' ]( X_EVENT_MEDIA_PLAYING );
+                                       return;
+                               };
                                
                                if( this.autoLoop ){
                                        if( !( this.disatcher[ 'dispatch' ]( X_EVENT_MEDIA_BEFORE_LOOP ) & X_CALLBACK_PREVENT_DEFAULT ) ){
@@ -426,15 +428,11 @@ if( X_WebAudio_context ){
                        actualPause : function(){
                                console.log( '[WebAudio] pause' );
                                
-                   //this._timerID && X_Timer_remove( this._timerID );
-                               //delete this._timerID;
                                this._interval && X_Timer_remove( this._interval );
                                delete this._interval;
                                delete this.playing;
 
                    if( this.bufferSource ){
-                       //if( this.bufferSource.onended ) delete this.bufferSource.onended;
-                       
                        this.bufferSource.stop ? 
                                this.bufferSource.stop( 0 ) : this.bufferSource[ 'noteOff' ]( 0 );
                    };
index ca59f5f..17ea8ab 100644 (file)
@@ -229,11 +229,10 @@ if( X_Audio_constructor ){
                                                // opera Android 12 で buffered.end() へのアクセスはエラー try catch も無効、iem9 は常に end(0) = 0\r
                                                if( X_HTMLAudio_progressEnabled && this.duration && this._readyState < 3 ){\r
                                                        buf  = raw.buffered;\r
-                                                       time = 0;\r
-                                                       for( i = 0, l = buf.length; i < l; ++i ){\r
+                                                       for( i = time = 0, l = buf && buf.length; i < l; ++i ){\r
                                                                time += buf[ 'end' ]( i ) - buf[ 'start' ]( i );\r
                                                        };\r
-                                                       this.disatcher[ 'dispatch' ]( { type : X_EVENT_PROGRESS, 'percent' : time * 1000 / this.duration } );\r
+                                                       this.disatcher[ 'dispatch' ]( { type : X_EVENT_PROGRESS, 'percent' : time * 1000 / this.duration * 100 } );\r
                                                };\r
                                                break;\r
                                        \r