リビジョン | b05bf97c1b3b1720e73af54017a48291a364d394 (tree) |
---|---|
日時 | 2016-03-30 07:33:27 |
作者 | itozyun <itozyun@user...> |
コミッター | itozyun |
Version 0.6.216, bug fixes X.WebAudio.
@@ -25,7 +25,10 @@ var | ||
25 | 25 | X_Class_traits = null, |
26 | 26 | X_Class_useObjectCreate = false, // !!Object.create, http://jsperf.com/prototype-vs-object-create-perf |
27 | 27 | // Opera Mobile 12.10 Android11 IS01 でクラスのメンバが欠落する問題に遭遇。__proto__ を辞めると動作,,, |
28 | - X_Class_use_proto_ = !X_UA[ 'OperaMobile' ] && !X_UA[ 'OperaTablet' ] && !!X_emptyFunction.prototype.__proto__, | |
28 | + X_Class_use_proto_ = !X_UA[ 'OperaMobile' ] && !X_UA[ 'OperaTablet' ] && | |
29 | + // Android で原因不明のエラーに遭遇しているのは、この辺りが怪しい... 2016.3.9 | |
30 | + !X_UA[ 'AOSP' ] && !X_UA[ 'ChromeWV' ] && | |
31 | + !!X_emptyFunction.prototype.__proto__, | |
29 | 32 | X_Class_constructorFix = X_UA[ 'AOSP' ] < 3 || X_UA[ 'iOS' ] < 5, |
30 | 33 | X_Class_SEAL_KILLING = [], |
31 | 34 |
@@ -202,6 +202,9 @@ function X_Node_animate( obj ){ | ||
202 | 202 | obj.phase = 4; // 強制停止(GPU転送予約)または値のみ更新 |
203 | 203 | obj.releaseNow = false; // TODO folower がいるため GPU 転送できないケースあり |
204 | 204 | X_NodeAnime_needsDetection = true; |
205 | + } else { | |
206 | + obj.phase = 1; | |
207 | + X_NodeAnime_needsDetection = true; | |
205 | 208 | }; |
206 | 209 | |
207 | 210 | if( !X_NodeAnime_reserved ){ |
@@ -85,6 +85,7 @@ function XMLWrapper_get( index ){ | ||
85 | 85 | |
86 | 86 | /** |
87 | 87 | * セレクターにヒットした要素の内容を指定されたデータ型で返す。複数要素にヒットした場合、0番目の要素の内容を使用する。 |
88 | + * '' をセレクタとして渡すとノードの値を返す | |
88 | 89 | * @alias X.XML.prototype.val |
89 | 90 | * @param {string} queryString XML セレクター文字列 |
90 | 91 | * @param {string} type 'number','int','boolean','string' |
@@ -6,7 +6,7 @@ | ||
6 | 6 | * AUTHOR: uupaa.js@gmail.com |
7 | 7 | * |
8 | 8 | */ |
9 | -var X_ImgLoader_image = window[ 'Image' ] && new Image(), | |
9 | +var X_ImgLoader_image = window[ 'Image' ] && new Image(), // ここで無用なアクセスをIEがしているかも | |
10 | 10 | // IE では厳密には HTMLImageElement ではなく、appendChild してもサイズが取れず、removeChild に失敗する |
11 | 11 | X_ImgLoader_isElement = !( X_UA[ 'IE' ] < 9 ) && X_Type_isHTMLElement( X_ImgLoader_image ), |
12 | 12 | // http://uupaa.hatenablog.com/entry/2013/12/17/171809 |
@@ -90,7 +90,7 @@ var X_WebAudio_context = // 4s 以下ではない iPad 2G または iPad mi | ||
90 | 90 | //!X_UA[ 'Blink' ] && |
91 | 91 | // Firefox40.0.5 + Windows8 で音声が途中から鳴らなくなる |
92 | 92 | // Firefox41.0.1 + Windows8 で音声が途中から鳴らなくなる |
93 | - !( 40 <= X_UA[ 'Gecko' ] && X_UA[ 'Gecko' ] < 45 && X_UA[ 'Windows' ] ) && | |
93 | + !( 40 <= X_UA[ 'Gecko' ] && X_UA[ 'Gecko' ] < 46 && X_UA[ 'Windows' ] ) && | |
94 | 94 | ( window[ 'AudioContext' ] || window[ 'webkitAudioContext' ] ), |
95 | 95 | X_WebAudio_BUFFER_LIST = [], |
96 | 96 | X_WebAudio_need1stTouch = X_UA[ 'iOS' ], |
@@ -229,7 +229,7 @@ if( X_WebAudio_context ){ | ||
229 | 229 | audioBuffer : null, |
230 | 230 | bufferSource : null, |
231 | 231 | gainNode : null, |
232 | - _onended : null, | |
232 | + //_onended : null, | |
233 | 233 | |
234 | 234 | 'Constructor' : function( disatcher, url, option ){ |
235 | 235 | var i = 0, |
@@ -280,7 +280,7 @@ if( X_WebAudio_context ){ | ||
280 | 280 | this.playing && this.actualPause(); |
281 | 281 | this.bufferSource && this._sourceDispose(); |
282 | 282 | |
283 | - this._onended && X_Closure_correct( this._onended ); | |
283 | + //this._onended && X_Closure_correct( this._onended ); | |
284 | 284 | |
285 | 285 | this.gainNode && this.gainNode.disconnect(); |
286 | 286 | }, |
@@ -334,17 +334,24 @@ if( X_WebAudio_context ){ | ||
334 | 334 | end = X_Audio_getEndTime( this ); |
335 | 335 | begin = X_Audio_getStartTime( this, end, true ); |
336 | 336 | |
337 | - console.log( '[WebAudio] play ' + begin + ' -> ' + end ); | |
337 | + console.log( '[WebAudio] play ' + begin + ' -> ' + end + ' loop: ' + this.autoLoop + ' :' + this.loopStartTime + ' -> ' + this.loopEndTime ); | |
338 | 338 | |
339 | 339 | if( this.bufferSource ) this._sourceDispose(); |
340 | 340 | if( !this.gainNode ){ |
341 | 341 | this.gainNode = X_WebAudio_context[ 'createGain' ] ? X_WebAudio_context[ 'createGain' ]() : X_WebAudio_context[ 'createGainNode' ](); |
342 | - this.gainNode[ 'connect' ]( X_WebAudio_context[ 'destination' ] ); | |
342 | + this.gainNode[ 'connect' ]( X_WebAudio_context[ 'destination' ] ); | |
343 | 343 | }; |
344 | + | |
344 | 345 | this.bufferSource = X_WebAudio_context[ 'createBufferSource' ](); |
345 | 346 | this.bufferSource.buffer = this.audioBuffer; |
346 | - this.bufferSource[ 'connect' ]( this.gainNode ); | |
347 | 347 | |
348 | + /* win8.1 Firefox45, win8.1 Chrome48 で動かなくなる... | |
349 | + if( this.bufferSource[ 'loop' ] = this.autoLoop ){ | |
350 | + this.bufferSource[ 'loopStart' ] = 0 <= this.loopStartTime ? this.loopStartTime / 1000 : begin / 1000; | |
351 | + this.bufferSource[ 'loopEnd' ] = 0 <= this.loopEndTime ? this.loopEndTime / 1000 : end / 1000; | |
352 | + }; */ | |
353 | + | |
354 | + this.bufferSource[ 'connect' ]( this.gainNode ); | |
348 | 355 | this.gainNode[ 'gain' ].value = this.gain; |
349 | 356 | |
350 | 357 | // おかしい、stop 前に外していても呼ばれる、、、@Firefox33.1 |
@@ -359,17 +366,19 @@ if( X_WebAudio_context ){ | ||
359 | 366 | //}; |
360 | 367 | |
361 | 368 | if( this.bufferSource.start ){ |
362 | - this.bufferSource.start( 0, begin / 1000, end / 1000 ); | |
369 | + this.bufferSource.start( 0, begin / 1000, ( end - begin ) / 1000 ); | |
370 | + } else | |
371 | + if( this.bufferSource[ 'noteOn' ] ){ | |
372 | + this.bufferSource[ 'noteOn' ]( 0, begin / 1000, ( end - begin ) / 1000 ); | |
363 | 373 | } else { |
364 | - this.bufferSource[ 'noteGrainOn' ]( 0, begin / 1000, end / 1000 ); | |
374 | + this.bufferSource[ 'noteGrainOn' ]( 0, begin / 1000, ( end - begin ) / 1000 ); | |
365 | 375 | }; |
366 | 376 | |
367 | 377 | this.playing = true; |
368 | 378 | this._startPos = begin; |
369 | 379 | this._endPosition = end; |
370 | 380 | this._startTime = X_WebAudio_context.currentTime * 1000; |
371 | - // this._interval = this._interval || X_Timer_add( 1000, 0, this, this._onInterval ); | |
372 | - this._interval = this._interval || X_Timer_add( 100, 0, this, this._onEnded ); | |
381 | + this._interval = this._interval || X_Timer_add( 100, 0, this, this._onInterval ); | |
373 | 382 | }, |
374 | 383 | |
375 | 384 | _sourceDispose : function(){ |
@@ -387,25 +396,18 @@ if( X_WebAudio_context ){ | ||
387 | 396 | this.disatcher[ 'dispatch' ]( X_EVENT_MEDIA_PLAYING ); |
388 | 397 | }, */ |
389 | 398 | |
390 | - _onEnded : function(){ | |
399 | + _onInterval : function(){ | |
391 | 400 | var time; |
392 | - //delete this._timerID; | |
393 | 401 | |
394 | 402 | if( this.playing ){ |
403 | + // TODO 再生中に終了時間だけ変えた場合! | |
395 | 404 | time = X_WebAudio_context.currentTime * 1000 - this._startTime - this._endPosition + this._startPos | 0; |
396 | 405 | //console.log( '> onEnd ' + ( this.playing && ( X_WebAudio_context.currentTime * 1000 - this._startTime ) ) + ' < ' + ( this._endPosition - this._startPos ) ); |
397 | - if( this._onended ){ | |
398 | - // Firefox 用の対策,,, | |
399 | - if( time < 0 ) return; | |
400 | - } else { | |
401 | - if( time < 0 ){ | |
402 | - this.disatcher[ 'dispatch' ]( X_EVENT_MEDIA_PLAYING ); | |
403 | - //console.log( '> onEnd crt:' + ( X_WebAudio_context.currentTime * 1000 ) + ' startTime:' + this._startTime + | |
404 | - // ' from:' + this._startPos + ' to:' + this._endPosition ); | |
405 | - // this._timerID = X_Timer_once( -time, this, this._onEnded ); | |
406 | - return; | |
407 | - }; | |
408 | - }; | |
406 | + | |
407 | + if( time < 0 ){ | |
408 | + this.disatcher[ 'dispatch' ]( X_EVENT_MEDIA_PLAYING ); | |
409 | + return; | |
410 | + }; | |
409 | 411 | |
410 | 412 | if( this.autoLoop ){ |
411 | 413 | if( !( this.disatcher[ 'dispatch' ]( X_EVENT_MEDIA_BEFORE_LOOP ) & X_CALLBACK_PREVENT_DEFAULT ) ){ |
@@ -426,15 +428,11 @@ if( X_WebAudio_context ){ | ||
426 | 428 | actualPause : function(){ |
427 | 429 | console.log( '[WebAudio] pause' ); |
428 | 430 | |
429 | - //this._timerID && X_Timer_remove( this._timerID ); | |
430 | - //delete this._timerID; | |
431 | 431 | this._interval && X_Timer_remove( this._interval ); |
432 | 432 | delete this._interval; |
433 | 433 | delete this.playing; |
434 | 434 | |
435 | 435 | if( this.bufferSource ){ |
436 | - //if( this.bufferSource.onended ) delete this.bufferSource.onended; | |
437 | - | |
438 | 436 | this.bufferSource.stop ? |
439 | 437 | this.bufferSource.stop( 0 ) : this.bufferSource[ 'noteOff' ]( 0 ); |
440 | 438 | }; |
@@ -229,11 +229,10 @@ if( X_Audio_constructor ){ | ||
229 | 229 | // opera Android 12 で buffered.end() へのアクセスはエラー try catch も無効、iem9 は常に end(0) = 0 |
230 | 230 | if( X_HTMLAudio_progressEnabled && this.duration && this._readyState < 3 ){ |
231 | 231 | buf = raw.buffered; |
232 | - time = 0; | |
233 | - for( i = 0, l = buf.length; i < l; ++i ){ | |
232 | + for( i = time = 0, l = buf && buf.length; i < l; ++i ){ | |
234 | 233 | time += buf[ 'end' ]( i ) - buf[ 'start' ]( i ); |
235 | 234 | }; |
236 | - this.disatcher[ 'dispatch' ]( { type : X_EVENT_PROGRESS, 'percent' : time * 1000 / this.duration } ); | |
235 | + this.disatcher[ 'dispatch' ]( { type : X_EVENT_PROGRESS, 'percent' : time * 1000 / this.duration * 100 } ); | |
237 | 236 | }; |
238 | 237 | break; |
239 | 238 |