@@ -155,14 +155,7 @@ var WebAudioSound = new Class({
155155 * @private
156156 */
157157 createAndStartLoopBufferSource : function ( ) {
158- var lastRateUpdateCurrentTime = 0 ;
159- for ( var i = 0 ; i < this . rateUpdates . length - 1 ; i ++ ) {
160- lastRateUpdateCurrentTime +=
161- ( this . rateUpdates [ i + 1 ] . time - this . rateUpdates [ i ] . time ) * this . rateUpdates [ i ] . rate ;
162- }
163- var lastRateUpdate = this . rateUpdates [ this . rateUpdates . length - 1 ] ;
164- var when = this . playTime + lastRateUpdate . time
165- + ( this . duration - lastRateUpdateCurrentTime ) / lastRateUpdate . rate ;
158+ var when = this . getLoopTime ( ) ;
166159 var offset = this . currentMarker ? this . currentMarker . start : 0 ;
167160 var duration = this . duration ;
168161 this . loopSource = this . createBufferSource ( ) ;
@@ -271,6 +264,19 @@ var WebAudioSound = new Class({
271264 currentTime += ( nextTime - this . rateUpdates [ i ] . time ) * this . rateUpdates [ i ] . rate ;
272265 }
273266 return currentTime ;
267+ } ,
268+ /**
269+ * @private
270+ */
271+ getLoopTime : function ( ) {
272+ var lastRateUpdateCurrentTime = 0 ;
273+ for ( var i = 0 ; i < this . rateUpdates . length - 1 ; i ++ ) {
274+ lastRateUpdateCurrentTime +=
275+ ( this . rateUpdates [ i + 1 ] . time - this . rateUpdates [ i ] . time ) * this . rateUpdates [ i ] . rate ;
276+ }
277+ var lastRateUpdate = this . rateUpdates [ this . rateUpdates . length - 1 ] ;
278+ return this . playTime + lastRateUpdate . time
279+ + ( this . duration - lastRateUpdateCurrentTime ) / lastRateUpdate . rate ;
274280 }
275281} ) ;
276282/**
0 commit comments