From e28511741c97176b8ffe67bb1ea0660da37f754b Mon Sep 17 00:00:00 2001 From: itozyun Date: Wed, 5 Aug 2015 14:31:21 +0900 Subject: [PATCH] Version 0.6.170, X.Audio is working ADVANCED_OPTIMIZATIONS. --- 0.6.x/css/xui.css | 14 ++--- 0.6.x/index.html | 2 +- 0.6.x/js/01_core/02_XUA.js | 2 +- 0.6.x/js/01_core/13_XClass.js | 2 +- 0.6.x/js/01_core/15_XEventDispatcher.js | 32 ++++++++---- 0.6.x/js/02_dom/10_XNodeAnime.js | 9 +--- 0.6.x/js/06_net/01_XNetXHR.js | 17 +++--- 0.6.x/js/07_audio/00_XAudio.js | 22 ++++---- 0.6.x/js/07_audio/01_XWebAudio.js | 75 ++++++++++++++------------- 0.6.x/js/07_audio/02_XHTMLAudio.js | 19 +++++-- 0.6.x/js/07_audio/03_XSilverlightAudio.js | 2 +- 0.6.x/js/07_audio/10_XAudioSprite.js | 12 ++++- 0.6.x/js/20_ui/{20_PageRoot.js => 20_Root.js} | 36 ++++++------- 0.6.x/js/main.js | 2 +- 14 files changed, 136 insertions(+), 110 deletions(-) rename 0.6.x/js/20_ui/{20_PageRoot.js => 20_Root.js} (87%) diff --git a/0.6.x/css/xui.css b/0.6.x/css/xui.css index 96374b9..cfebdab 100644 --- a/0.6.x/css/xui.css +++ b/0.6.x/css/xui.css @@ -35,12 +35,12 @@ font-family: 'MS Pゴシック',sans-serif; } -.PageRoot { +.Root { height : 100%; } -.PageRoot, -.PageRoot div { +.Root, +.Root div { /* 要素は絶対配置される */ position : absolute; top : 0; @@ -73,12 +73,12 @@ white-space : -moz-pre-wrap; /* Mozilla */ /* white-space : -hp-pre-wrap; HP Printers */ } -.IE5x .PageRoot, .IE5x .PageRoot div, -.IE6 .PageRoot, .IE6 .PageRoot div, -.IE7 .PageRoot, .IE7 .PageRoot div, { +.IE5x .Root, .IE5x .Root div, +.IE6 .Root, .IE6 .Root div, +.IE7 .Root, .IE7 .Root div, { word-break : break-all; /* ie5+ */ } -.IE .PageRoot, .IE .PageRoot div { +.IE .Root, .IE .Root div { white-space : normal/* ie系では、 float要素へ回り込みする、 white-space の効いているテキストの位置が狂う */ } diff --git a/0.6.x/index.html b/0.6.x/index.html index 43d4c63..b66af41 100644 --- a/0.6.x/index.html +++ b/0.6.x/index.html @@ -30,7 +30,7 @@ - + diff --git a/0.6.x/js/01_core/02_XUA.js b/0.6.x/js/01_core/02_XUA.js index b99223a..3ce9532 100644 --- a/0.6.x/js/01_core/02_XUA.js +++ b/0.6.x/js/01_core/02_XUA.js @@ -545,7 +545,7 @@ var X_UA = X[ 'UA' ] = {}, * @type {number} */ X_UA[ 'AndroidWebkit' ] = i; - alert( 'AudioSprite調査:Android標準ブラウザ Webkit Version ' + i ); + //alert( 'AudioSprite調査:Android標準ブラウザ Webkit Version ' + i ); } else if( i = parseFloat(dua.split('WebKit\/')[1]) ){ diff --git a/0.6.x/js/01_core/13_XClass.js b/0.6.x/js/01_core/13_XClass.js index 45747b1..6cf56b8 100644 --- a/0.6.x/js/01_core/13_XClass.js +++ b/0.6.x/js/01_core/13_XClass.js @@ -92,7 +92,7 @@ X_Class_CommonMethods = }; if( this[ 'instanceOf' ]( Node ) ){ - console.log( 'KILL : ' + this.call( 'outerHTML' ) ); + // console.log( 'KILL : ' + this.call( 'outerHTML' ) ); X_Node_onKill( this ); }; diff --git a/0.6.x/js/01_core/15_XEventDispatcher.js b/0.6.x/js/01_core/15_XEventDispatcher.js index 5a5b17d..91e10b8 100644 --- a/0.6.x/js/01_core/15_XEventDispatcher.js +++ b/0.6.x/js/01_core/15_XEventDispatcher.js @@ -15,7 +15,7 @@ *
dispatch 中か?さらにインスタンス自身の dispatch がネストした場合、その深さを記憶します。 *
2:RESERVES Array *
イベント発火中に listen() が呼ばれた場合に引数を蓄え、完了時(DISPATCHING===0)に再度 listen() するための一時ストアです。 - *
3:UNLISTENS Array + *
3:UNLISTENS Object *
イベント発火中に unlisten() が呼ばれた場合に対象リスナを記憶し、リスナが呼ばれないようにします。完了時(DISPATCHING===0)に再度 unlisten() します。 *
4:KILL_RESERVED boolean *
dispatch 中に kill() が呼ばれた場合に一旦 kill をキャンセルし、完了時(DISPATCHING===0)に再度 kill() するためのフラグです。 @@ -176,7 +176,7 @@ var X_EventDispatcher = X[ 'EventDispatcher' ] = if( !listeners || !( list = listeners[ opt_type ] ) ) return false; if( opt_arg1 === undefined ) return X_EventDispatcher_needsIndex ? 0 : true; - // TODO callbackHash か?判定が不十分! + // TODO callbackHash か?判定が不十分! skipConvertion if( opt_arg1.kind ){ cbHash = opt_arg1; } else { @@ -189,6 +189,7 @@ var X_EventDispatcher = X[ 'EventDispatcher' ] = if( f === cbHash || ( f.context === cbHash.context && f.func === cbHash.func && f.name === cbHash.name && f.supplement === cbHash.supplement && f.lock === lock ) ) return false; }; }; + for( i = list.length; i; ){ f = list[ --i ]; if( f === cbHash || ( f.context === cbHash.context && f.func === cbHash.func && f.name === cbHash.name && f.supplement === cbHash.supplement && f.lock === lock ) ){ @@ -215,6 +216,9 @@ var X_EventDispatcher = X[ 'EventDispatcher' ] = e = delay; delay = 0; }; + //{+dev + delay === undefined && eval( 'throw "asyncDispatch で undefined イベントが指定されました"' ); + //}+dev timerID = X_Timer_add( delay, 1, this, X_EventDispatcher_dispatch, [ e ] ); X_EventDispatcher_LAZY_TIMERS[ timerID ] = this; return timerID; @@ -255,22 +259,24 @@ function X_EventDispatcher_dispatch( e ){ } else { listeners[ X_LISTENERS_DISPATCHING ] = 1; }; - - // todo: - // type も保存 - listeners[ X_LISTENERS_UNLISTENS ] = listeners[ X_LISTENERS_UNLISTENS ] || {}; - unlistens = listeners[ X_LISTENERS_UNLISTENS ][ type ]; + + //listeners[ X_LISTENERS_UNLISTENS ] = listeners[ X_LISTENERS_UNLISTENS ] || {}; + //unlistens = listeners[ X_LISTENERS_UNLISTENS ][ type ]; for( i = 0; i < list.length; ++i ){ f = list[ i ]; + // TODO removed フラグは? + if( f.removed ) continue; + /* if( !unlistens ){ unlistens = listeners[ X_LISTENERS_UNLISTENS ][ type ]; }; if( unlistens && unlistens.indexOf( f ) !== -1 ) continue; + */ - r = X_Closure_proxyCallback( f, args || ( args = [ e ] ) ) || 0; + r = X_Closure_proxyCallback( f, args || ( args = [ e ] ) ); - if( f.once || r & X_CALLBACK_UN_LISTEN ){ + if( f.once || ( r & X_CALLBACK_UN_LISTEN ) ){ // dispatch 中に unlisten が作られることがある if( !unlistens ){ unlistens = listeners[ X_LISTENERS_UNLISTENS ] || ( listeners[ X_LISTENERS_UNLISTENS ] = {} ); @@ -455,13 +461,17 @@ function X_EventDispatcher_unlisten( opt_type, opt_arg1, opt_arg2, opt_arg3 ){ f = ( list = listeners[ opt_type ] )[ i ]; - if( unlistens = listeners[ X_LISTENERS_UNLISTENS ] ){ + if( listeners[ X_LISTENERS_DISPATCHING ] ){ + unlistens = listeners[ X_LISTENERS_UNLISTENS ] || ( listeners[ X_LISTENERS_UNLISTENS ] = {} ); // _unlistens に入っている callbackHash は、lock のチェックは済んでいる ( unlistens = unlistens[ opt_type ] ) ? ( unlistens[ unlistens.length ] = f ) : ( listeners[ X_LISTENERS_UNLISTENS ][ opt_type ] = [ f ] ); + f.removed = true; } else { - delete f.once; + //delete f.once; + X_Object_clear( f ); + if( list.length !== 1 ){ list.splice( i, 1 ); } else { diff --git a/0.6.x/js/02_dom/10_XNodeAnime.js b/0.6.x/js/02_dom/10_XNodeAnime.js index 003b89c..1c95264 100644 --- a/0.6.x/js/02_dom/10_XNodeAnime.js +++ b/0.6.x/js/02_dom/10_XNodeAnime.js @@ -65,7 +65,7 @@ var X_Node_ANIMATIONS = [], X_Node_Anime_hasTransform = !!X_Node_CSS_VENDER_PREFIX[ 'transform' ], /* Opera mobile で translateZ(0) が有効だと XY が 0 0 になる */ - /* GPUレイヤーにいる間に要素のコンテンツを変更をすると transitionend が動かなくなるっぽい Mac safari と firefox, 手当てが済むまでここは常に false */ + /* GPUレイヤーにいる間に要素のコンテンツを変更をすると transitionend が動かなくなるっぽい Mac safari と firefox */ X_Node_Anime_translateZ = X_Node_CSS_VENDER_PREFIX[ 'perspective' ] && !X_UA[ 'OperaMobile' ] && !X_UA[ 'OperaTablet' ] ? ' translateZ(0)' : '', /* Opera12(XP,8.1) 切った方がスムース, win Safari3 で、たまに動作が止まってしまう、、、 */ X_Node_Anime_hasTransition = !!X_Node_CSS_VENDER_PREFIX[ 'transitionDelay' ] && !X_UA[ 'Opera' ], // && !( X_UA[ 'Webkit' ] <= 528.16 ), @@ -292,9 +292,6 @@ function X_Node_Anime_detectAnimationLayers(){ X_Node_Anime_needsDetection = false; }; -/* TODO - * 0:無, 1:子のGPU解除待 2:GPU予約, 3:GPU now!, 4:GPU解除予約 - */ function X_Node_Anime_updateAnimation( xnode ){ var obj = xnode[ '_anime' ], phase = obj.phase, @@ -344,14 +341,13 @@ function X_Node_Anime_updateAnimation( xnode ){ //console.log( 'duration = 0 の場合、アニメーションの解除' ); // duration = 0 の場合、アニメーションの解除 - case 3 : // アニメーションの解除 + case 3 : // TransitionEnd -> アニメーションの解除 obj.phase = obj.gpuParent ? 10 : 4; console.log( '#### アニメーションの解除 ' + obj.phase ); // このタイミングで animation 関連の css を削除したところ(X_Node_Anime_clearTransition)、iOS3、4 で再描画忘れが度々起きるように、、、 if( !obj.gpuParent ) X_Node_Anime_clearTransition( xnode ); - //xnode[ 'dispatch' ]( { type : X_EVENT_ANIME_END, 'gpu' : obj.gpuParent } ); break; case 4 : @@ -361,7 +357,6 @@ function X_Node_Anime_updateAnimation( xnode ){ case 10 : // アニメーションは停止・GPUレイヤーは解除していない(再アニメーションに備えて待機) - //X_Node_Anime_clearTransition( xnode ); // TODO X_Node_Anime_releaseGPULayer に移動? if( !obj.gpuTimerID ){ console.log( '#### アニメーションは停止 ' + obj.wait ); if( obj.wait ){ diff --git a/0.6.x/js/06_net/01_XNetXHR.js b/0.6.x/js/06_net/01_XNetXHR.js index 0531a29..785bcbf 100644 --- a/0.6.x/js/06_net/01_XNetXHR.js +++ b/0.6.x/js/06_net/01_XNetXHR.js @@ -74,7 +74,7 @@ var // Opera7.6+, Safari1.2+, khtml3.?+, Gecko0.9.7+ X_Net_XHR_msXMLVer = 0, X_Net_XHR_msXML = X_Net_XHR_createMSXML && X_Net_XHR_createMSXML( true ), - X_Net_XHR_neverReuse = X_UA[ 'IE' ] < 9, // ie7,8 の xhr はリユース不可。msxml はリユース可能。 + X_Net_XHR_neverReuse = X_UA[ 'IE' ] < 9 || X_UA[ 'iOS' ] || X_UA[ 'Android' ], // ie7,8 の xhr はリユース不可。msxml はリユース可能。 X_Net_XHR_TYPE_FLASH = 8, X_Net_XHR_TYPE_GADGET = 16; @@ -470,7 +470,6 @@ X_TEMP.X_Net_XHR_params = { data = raw[ 'response' ] || raw[ 'responseText' ]; // とりあえず break; }; - X_NET_XHRWrapper[ 'asyncDispatch' ]( 32, { type : X_EVENT_SUCCESS, status : status || 200, response : data, 'headers' : headers || null } ); } else { X_NET_XHRWrapper[ 'asyncDispatch' ]( 32, { type : X_EVENT_ERROR, status : status || 400, 'headers' : headers || null } ); @@ -479,8 +478,8 @@ X_TEMP.X_Net_XHR_params = { case 'progress' : if( e.lengthComputable ){ - X_NET_XHRWrapper._percent = e.loaded / e.total; - live && X_NET_XHRWrapper[ 'asyncDispatch' ]( { type : X_EVENT_PROGRESS, 'percent' : X_NET_XHRWrapper._percent } ); + X_NET_XHRWrapper._percent = e.loaded / e.total * 100; + live && X_NET_XHRWrapper._percent < 100 && X_NET_XHRWrapper[ 'asyncDispatch' ]( { type : X_EVENT_PROGRESS, 'percent' : X_NET_XHRWrapper._percent } ); }; break; @@ -511,10 +510,12 @@ X_TEMP.X_Net_XHR_params = { }, onUploadProgress : X_Net_XHR_upload && function( e ){ - var raw = X_NET_XHRWrapper[ '_rawObject' ].upload, - live = !X_NET_XHRWrapper._canceled, - states, data; - live && X_NET_XHRWrapper[ 'asyncDispatch' ]( { type : X_EVENT_PROGRESS, 'percent' : X_NET_XHRWrapper._percent, 'uploadPercent' : ( e.loaded / e.total ) } ); + !X_NET_XHRWrapper._canceled && + X_NET_XHRWrapper[ 'asyncDispatch' ]( { + type : X_EVENT_PROGRESS, + 'percent' : X_NET_XHRWrapper._percent, + 'uploadPercent' : e.loaded / e.total * 100 + } ); } }; // 同期リクエストでなければならない場合, unload, beforeunload時 diff --git a/0.6.x/js/07_audio/00_XAudio.js b/0.6.x/js/07_audio/00_XAudio.js index 783e885..b12e679 100644 --- a/0.6.x/js/07_audio/00_XAudio.js +++ b/0.6.x/js/07_audio/00_XAudio.js @@ -271,12 +271,12 @@ var X_Audio_AbstractAudioBackend = X_EventDispatcher[ 'inherits' ]( play : function( startTime, endTime, loop, loopStartTime, loopEndTime ){ if( 0 <= startTime ){ this.setState( { - currentTime : startTime, - startTime : startTime, - endTime : endTime, - loop : loop, - loopStartTime : loopStartTime, - loopEndTime : loopEndTime + 'currentTime' : startTime, + 'startTime' : startTime, + 'endTime' : endTime, + 'loop' : loop, + 'loopStartTime' : loopStartTime, + 'loopEndTime' : loopEndTime } ); }; this.actualPlay(); @@ -284,7 +284,7 @@ var X_Audio_AbstractAudioBackend = X_EventDispatcher[ 'inherits' ]( seek : function( seekTime ){ if( seekTime < X_AudioWrapper_getEndTime( this ) ){ - this.setState( { currentTime : seekTime } ); + this.setState( { 'currentTime' : seekTime } ); }; }, @@ -296,21 +296,21 @@ var X_Audio_AbstractAudioBackend = X_EventDispatcher[ 'inherits' ]( if( v === undefined ){ return this.autoLoop; }; - this.setState( { loop : v } ); + this.setState( { 'loop' : v } ); }, volume : function( v ){ if( v === undefined ){ return this.gain; }; - this.setState( { volume : v } ); + this.setState( { 'volume' : v } ); }, currentTime : function( v ){ if( v === undefined ){ return this.playing ? this.getActualCurrentTime() : this.seekTime; }; - this.setState( { currentTime : v } ); + this.setState( { 'currentTime' : v } ); }, getState : function(){ @@ -432,6 +432,8 @@ var X_Audio_AbstractAudioBackend = X_EventDispatcher[ 'inherits' ]( }; }; break; + default : + throw 'bad arg'; }; }; diff --git a/0.6.x/js/07_audio/01_XWebAudio.js b/0.6.x/js/07_audio/01_XWebAudio.js index e8fd81b..dd90819 100644 --- a/0.6.x/js/07_audio/01_XWebAudio.js +++ b/0.6.x/js/07_audio/01_XWebAudio.js @@ -1,7 +1,8 @@ var X_Audio_WebAudio_context = !X_UA[ 'iPhone_4s' ] && !X_UA[ 'iPad_2Mini1' ] && !X_UA[ 'iPod_4' ] && + // TODO なんで fennec を禁止? !( X_UA[ 'Gecko' ] && X_UA[ 'Android' ] ) && - ( window.AudioContext || window.webkitAudioContext ), + ( window[ 'AudioContext' ] || window[ 'webkitAudioContext' ] ), X_Audio_BUFFER_LIST = [], X_Audio_WebAudioWrapper, X_Audio_BufferLoader; @@ -14,7 +15,7 @@ if( X_Audio_WebAudio_context ){ X_Audio_WebAudio_context = new X_Audio_WebAudio_context; X_Audio_BufferLoader = X_EventDispatcher[ 'inherits' ]( - 'X.AV.WebAudioBufferLoader', + 'X.WebAudio.BufferLoader', X_Class.POOL_OBJECT, { url : '', @@ -26,10 +27,10 @@ if( X_Audio_WebAudio_context ){ error : 0, webAudioList : null, - Constructor : function( webAudio, url ){ + 'Constructor' : function( webAudio, url ){ this.webAudioList = [ webAudio ]; this.url = url; - this.xhr = X.Net( { 'xhr' : url, 'dataType' : 'arraybuffer' } ) + this.xhr = X[ 'Net' ]( { 'xhr' : url, 'dataType' : 'arraybuffer' } ) [ 'listen' ]( X_EVENT_PROGRESS, this ) [ 'listenOnce' ]( [ X_EVENT_SUCCESS, X_EVENT_COMPLETE ], this ); }, @@ -48,15 +49,13 @@ if( X_Audio_WebAudio_context ){ // iOS 7.1 で decodeAudioData に処理が入った瞬間にスクリーンを長押しする(スクロールを繰り返す)と // decoeAudioData の処理がキャンセルされることがある(エラーやコールバックの発火もなく、ただ処理が消滅する)。 // ただし iOS 8.1.2 では エラーになる - if( X_Audio_WebAudio_context.createBuffer && X_UA[ 'iOS' ] < 8 ){ - this._onDecodeSuccess( X_Audio_WebAudio_context.createBuffer( e.response, false ) ); + if( X_UA[ 'iOS' ] < 8 || !X_Audio_WebAudio_context[ 'decodeAudioData' ] ){ + this._onDecodeSuccess( X_Audio_WebAudio_context[ 'createBuffer' ]( e.response, false ) ); } else - if( X_Audio_WebAudio_context.decodeAudioData ){ - X_Audio_WebAudio_context.decodeAudioData( e.response, + if( X_Audio_WebAudio_context[ 'decodeAudioData' ] ){ + X_Audio_WebAudio_context[ 'decodeAudioData' ]( e.response, this.onDecodeSuccess = X_Closure_create( this, this._onDecodeSuccess ), this.onDecodeError = X_Closure_create( this, this._onDecodeError ) ); - } else { - this._onDecodeSuccess( X_Audio_WebAudio_context.createBuffer( e.response, false ) ); }; break; @@ -118,7 +117,7 @@ if( X_Audio_WebAudio_context ){ X_Audio_WebAudioWrapper = X_Audio_AbstractAudioBackend[ 'inherits' ]( - 'X.AV.WebAudioWrapper', + 'X.WebAudio', X_Class.POOL_OBJECT, { @@ -130,11 +129,11 @@ if( X_Audio_WebAudio_context ){ _timerID : 0, _interval : 0, buffer : null, - source : null, + bufferSource : null, gainNode : null, _onended : null, - Constructor : function( target, url, option ){ + 'Constructor' : function( target, url, option ){ var i = 0, l = X_Audio_BUFFER_LIST.length, loader; @@ -171,12 +170,12 @@ if( X_Audio_WebAudio_context ){ delete this.buffer; - this.playing && this.actualPause(); - this.source && this._sourceDispose(); + 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(); + this.gainNode && this.gainNode.disconnect(); }, _onLoadBufferComplete : function( e ){ var loader = this.loader, @@ -203,6 +202,8 @@ if( X_Audio_WebAudio_context ){ this.target[ 'asyncDispatch' ]( X_EVENT_READY ); + console.log( 'WebAudio buffer ready' ); + this.autoplay && X_Timer_once( 16, this, this.play ); }, @@ -220,31 +221,31 @@ if( X_Audio_WebAudio_context ){ console.log( '[WebAudio] play ' + begin + ' -> ' + end ); - if( this.source ) this._sourceDispose(); + if( this.bufferSource ) this._sourceDispose(); if( !this.gainNode ){ - this.gainNode = X_Audio_WebAudio_context.createGain ? X_Audio_WebAudio_context.createGain() : X_Audio_WebAudio_context.createGainNode(); - this.gainNode.connect( X_Audio_WebAudio_context.destination ); + this.gainNode = X_Audio_WebAudio_context[ 'createGain' ] ? X_Audio_WebAudio_context[ 'createGain' ]() : X_Audio_WebAudio_context[ 'createGainNode' ](); + this.gainNode[ 'connect' ]( X_Audio_WebAudio_context[ 'destination' ] ); }; - this.source = X_Audio_WebAudio_context.createBufferSource(); - this.source.buffer = this.buffer; - this.source.connect( this.gainNode ); + this.bufferSource = X_Audio_WebAudio_context[ 'createBufferSource' ](); + this.bufferSource.buffer = this.buffer; + this.bufferSource[ 'connect' ]( this.gainNode ); - this.gainNode.gain.value = this.gain; + this.gainNode[ 'gain' ].value = this.gain; // おかしい、stop 前に外していても呼ばれる、、、@Firefox33.1 // 破棄された X.Callback が呼ばれて、obj.proxy() でエラーになる。Firefox では、onended は使わない - if( false && this.source.onended !== undefined ){ + if( false && this.bufferSource.onended !== undefined ){ //console.log( '> use onended' ); - this.source.onended = this._onended || ( this._onended = X_Closure_create( this, this._onEnded ) ); + this.bufferSource.onended = this._onended || ( this._onended = X_Closure_create( this, this._onEnded ) ); } else { this._timerID && X_Timer_remove( this._timerID ); this._timerID = X_Timer_once( end - begin, this, this._onEnded ); }; - if( this.source.start ){ - this.source.start( 0, begin / 1000, end / 1000 ); + if( this.bufferSource.start ){ + this.bufferSource.start( 0, begin / 1000, end / 1000 ); } else { - this.source.noteGrainOn( 0, begin / 1000, end / 1000 ); + this.bufferSource[ 'noteGrainOn' ]( 0, begin / 1000, end / 1000 ); }; this.playing = true; @@ -255,9 +256,9 @@ if( X_Audio_WebAudio_context ){ }, _sourceDispose : function(){ - this.source.disconnect(); - delete this.source.onended; - delete this.source; + this.bufferSource.disconnect(); + delete this.bufferSource.onended; + delete this.bufferSource; }, _onInterval : function(){ @@ -311,11 +312,11 @@ if( X_Audio_WebAudio_context ){ delete this._timerID; delete this.playing; - if( this.source ){ - if( this.source.onended ) delete this.source.onended; + if( this.bufferSource ){ + if( this.bufferSource.onended ) delete this.bufferSource.onended; - this.source.stop ? - this.source.stop( 0 ) : this.source.noteOff( 0 ); + this.bufferSource.stop ? + this.bufferSource.stop( 0 ) : this.bufferSource[ 'noteOff' ]( 0 ); }; }, @@ -328,7 +329,7 @@ if( X_Audio_WebAudio_context ){ this.actualPlay(); } else if( result & 4 ){ - this.gainNode.gain.value = this.gain; + this.gainNode[ 'gain' ].value = this.gain; }; } diff --git a/0.6.x/js/07_audio/02_XHTMLAudio.js b/0.6.x/js/07_audio/02_XHTMLAudio.js index 7206221..3972841 100644 --- a/0.6.x/js/07_audio/02_XHTMLAudio.js +++ b/0.6.x/js/07_audio/02_XHTMLAudio.js @@ -87,7 +87,7 @@ if( X_Audio_constructor && !X_Audio_HTMLAudioWrapper_badOperaAndroid ){ _lastCurrentTime : 0, _src : '', - Constructor : function( target, source, option ){ + 'Constructor' : function( target, source, option ){ var raw; this.target = target || this; @@ -168,7 +168,10 @@ if( X_Audio_constructor && !X_Audio_HTMLAudioWrapper_badOperaAndroid ){ X_Audio_HTMLAudioWrapper_badOperaAndroid && alert( e.type ); - X_Audio_HTMLAudioWrapper_ieMobile9Fix && e.type !== 'timeupdate' && console.log( e.type ); + // global に公開 + window[ '__rawAudio' ] = this[ '_rawObject' ]; + + /* X_Audio_HTMLAudioWrapper_ieMobile9Fix && */ e.type !== 'timeupdate' && console.log( e.type ); switch( e.type ){ case 'loadstart' : // ブラウザがコンテンツの検索を開始した場合に発生 @@ -241,6 +244,7 @@ if( X_Audio_constructor && !X_Audio_HTMLAudioWrapper_badOperaAndroid ){ delete this.playing; break; + // TODO firefox で 短い音声でtimeupdate, ended が発火しない case 'timeupdate' : // 通常の再生が行われ現在の再生位置の変化が起こった場合に発生 if( X_Audio_HTMLAudioWrapper_ieMobile9Fix ){ if( this._playForDuration === 1 ){ @@ -268,7 +272,7 @@ if( X_Audio_constructor && !X_Audio_HTMLAudioWrapper_badOperaAndroid ){ if( this.playing ){ end = X_AudioWrapper_getEndTime( this ); now = this.getActualCurrentTime(); - console.log( end + ' / ' + now ); + console.log( now + ' / ' + end ); if( 0 + end <= 0 + now ){ // なぜか iem9 で必要,,, if( this.autoLoop ){ if( !( this.target[ 'dispatch' ]( X_EVENT_MEDIA_BEFORE_LOOP ) & X_CALLBACK_PREVENT_DEFAULT ) ){ @@ -365,7 +369,7 @@ if( X_Audio_constructor && !X_Audio_HTMLAudioWrapper_badOperaAndroid ){ begin = this._beginTime = X_AudioWrapper_getStartTime( this, end, true ); if( X_Audio_HTMLAudioWrapper_shortPlayFix ){ - begin -= end - begin > 1000 ? 200 : 400; + begin -= ( end - begin > 1000 ) ? 200 : 400; begin = begin < 0 ? 0 : begin; }; @@ -385,11 +389,16 @@ if( X_Audio_constructor && !X_Audio_HTMLAudioWrapper_badOperaAndroid ){ }; this[ '_rawObject' ].play(); this.playing = true; + } else + if( X_UA[ 'Gecko' ] ){ + // Gecko PC + Android でseek時に再生がしばしば止まる問題の修正 + this[ '_rawObject' ].play(); }; + //http://himaxoff.blog111.fc2.com/blog-entry-97.html //Firefox3.6では一度も play() していない状態で currentTime = 0 を実行するとエラーになる。 //また、GoogleChrome7 では currentTime = 0 直後に play() すると、pause()した位置前後の音が混ざることがある。(少なくとも自分の環境では) - this[ '_rawObject' ].currentTime = this._lastCurrentTime = begin / 1000; + this[ '_rawObject' ].currentTime = this._lastCurrentTime = begin / 1000 | 0; console.log( '[HTMLAudio] play ' + begin + ' -> ' + end ); diff --git a/0.6.x/js/07_audio/03_XSilverlightAudio.js b/0.6.x/js/07_audio/03_XSilverlightAudio.js index c716a9a..6999b81 100644 --- a/0.6.x/js/07_audio/03_XSilverlightAudio.js +++ b/0.6.x/js/07_audio/03_XSilverlightAudio.js @@ -45,7 +45,7 @@ if( X[ 'Pulgin' ][ 'SilverlightEnabled' ] ){ _lastState : '', _interval : 0, // setInterval timer id - Constructor : function( target, source, option ){ + 'Constructor' : function( target, source, option ){ !X_Audio_SLAudio_uid && X_TEMP.slaudioInit(); /* diff --git a/0.6.x/js/07_audio/10_XAudioSprite.js b/0.6.x/js/07_audio/10_XAudioSprite.js index 8c86151..ac5b19e 100644 --- a/0.6.x/js/07_audio/10_XAudioSprite.js +++ b/0.6.x/js/07_audio/10_XAudioSprite.js @@ -304,12 +304,18 @@ function X_AudioSprite_backendHandler( e ){ this[ 'source' ] = src = e[ 'source' ]; this[ 'backendName' ] = name = backend.backendName; + console.log( i + ' / ' + X_Audio_Sprite_numTracks ); + for( i = 0; i < X_Audio_Sprite_numTracks; ++i ){ if( X_Audio_Sprite_useVideo || ( i === 1 && X_Audio_Sprite_useVideoForMulti ) ){ option[ 'useVideo' ] = true; }; // Audiobackend の owner として null を渡すとAudioBackend 自身へ dispatch する X_Audio_Sprite_TEMP.tracks.push( last = backend.klass( null, e[ 'source' ], option ) ); + + + console.dir( backend ); + console.dir( last ); }; _e = { @@ -327,6 +333,8 @@ function X_AudioSprite_backendHandler( e ){ }; this[ 'asyncDispatch' ]( _e ); + console.log( 'AudioSprite - X_EVENT_BACKEND_READY' ); + last[ 'listenOnce' ]( X_EVENT_READY, this, X_AudioSprite_backendHandler ); // READY, needTouchForPlay, needTouchForLoad @@ -350,7 +358,7 @@ function X_AudioSprite_backendHandler( e ){ for( i = 0; i < X_Audio_Sprite_TEMP.tracks.length; ++i ){ this[ 'pause' ]( i ); }; - e.target[ 'listenOnce' ]( X_EVENT_MEDIA_PLAYING, this, this.asyncDispatch, [ X_EVENT_READY ] ); // Android 標準ブラウザ + e.target[ 'listenOnce' ]( X_EVENT_MEDIA_PLAYING, this, this[ 'asyncDispatch' ], [ X_EVENT_READY ] ); // Android 標準ブラウザ return; }; this[ 'asyncDispatch' ]( X_EVENT_READY ); @@ -384,7 +392,7 @@ function X_Audio_Sprite_handleEvent( e ){ if( X_Audio_Sprite_TEMP.bgmPlaying && !X_Audio_Sprite_TEMP.bgmTrack ){ X_Audio_Sprite_TEMP.bgmTrack = e.target; this.play( X_Audio_Sprite_TEMP.bgmName ); - return X.Callback.PREVENT_DEFAULT; + return X_CALLBACK_PREVENT_DEFAULT; }; }; break; diff --git a/0.6.x/js/20_ui/20_PageRoot.js b/0.6.x/js/20_ui/20_Root.js similarity index 87% rename from 0.6.x/js/20_ui/20_PageRoot.js rename to 0.6.x/js/20_ui/20_Root.js index 09ca3c5..e1a756f 100644 --- a/0.6.x/js/20_ui/20_PageRoot.js +++ b/0.6.x/js/20_ui/20_Root.js @@ -67,8 +67,8 @@ function X_UI_eventRellay( e ){ * 背景画像を読み終える onload で活動開始 */ -var XUI_PageRoot = XUI_Box.inherits( - '_PageRoot', +var XUI_Root = XUI_Box.inherits( + '_Root', X_Class.FINAL, { layout : XUI_Layout_Canvas, @@ -124,10 +124,10 @@ var XUI_PageRoot = XUI_Box.inherits( X_Timer_once( 0, this, this.afterAddToView ); }, afterAddToView : function(){ - this.xnode[ 'className' ]( 'PageRoot' ); + this.xnode[ 'className' ]( 'Root' ); this.creationComplete(); - X_Timer_once( 0, this, XUI_PageRoot_do1stCalculate ); + X_Timer_once( 0, this, XUI_Root_do1stCalculate ); }, reserveCalc : function(){ @@ -151,7 +151,7 @@ var XUI_PageRoot = XUI_Box.inherits( this.calcReserved = false; - X_ViewPort[ 'listenOnce' ]( X_EVENT_AFTER_UPDATE, this, XUI_PageRoot_onViewUpdate ); + X_ViewPort[ 'listenOnce' ]( X_EVENT_AFTER_UPDATE, this, XUI_Root_onViewUpdate ); return X_CALLBACK_NONE; }, @@ -167,7 +167,7 @@ var XUI_PageRoot = XUI_Box.inherits( } ); -function XUI_PageRoot_do1stCalculate(){ +function XUI_Root_do1stCalculate(){ this.calculate(); this.phase = 4; X.ViewPort @@ -175,36 +175,36 @@ function XUI_PageRoot_do1stCalculate(){ [ 'listen' ]( X_EVENT_BASE_FONT_RESIZED, this, this.calculate ); }; -function XUI_PageRoot_onViewUpdate( e ){ +function XUI_Root_onViewUpdate( e ){ this[ 'dispatch' ]( XUI_Event.LAYOUT_COMPLETE ); }; -//var XUI_PageRoot; +//var XUI_Root; // TODO singleton -X.UI.PageRoot = X.UI.Box.inherits( - 'PageRoot', +X.UI.Root = X.UI.Box.inherits( + 'Root', X_Class.NONE, { Constructor : function(){ var supports; - //if( !XUI_PageRoot ){ + //if( !XUI_Root ){ supports = XUI_Attr_createAttrDef( XUI_Box.prototype.usableAttrs, XUI_Layout_Canvas.overrideAttrsForSelf ); - XUI_PageRoot.prototype.layout = XUI_Layout_Canvas; - XUI_PageRoot.prototype.usableAttrs = supports; - XUI_PageRoot.prototype.attrClass = XUI_Attr_preset( XUI_Box.prototype.attrClass, supports, { + XUI_Root.prototype.layout = XUI_Layout_Canvas; + XUI_Root.prototype.usableAttrs = supports; + XUI_Root.prototype.attrClass = XUI_Attr_preset( XUI_Box.prototype.attrClass, supports, { width : '100%', height : '100%' } ); //}; - X_Pair_create( this, XUI_PageRoot( this, XUI_Layout_Canvas, arguments ) ); + X_Pair_create( this, XUI_Root( this, XUI_Layout_Canvas, arguments ) ); } }); /* -X.UI.PageRoot = X.UI.Box.presets( - 'PageRoot', - XUI_PageRoot, +X.UI.Root = X.UI.Box.presets( + 'Root', + XUI_Root, { width : '100%', height : '100%' diff --git a/0.6.x/js/main.js b/0.6.x/js/main.js index abe9b58..874940a 100644 --- a/0.6.x/js/main.js +++ b/0.6.x/js/main.js @@ -1,7 +1,7 @@ var scroll; with( X.UI ){ - PageRoot( + Root( scroll = ScrollBox( Layout.Canvas, { -- 2.11.0