|
@@ -21,6 +21,7 @@ function Audio( listener ) {
|
|
|
this.buffer = null;
|
|
|
this.loop = false;
|
|
|
this.startTime = 0;
|
|
|
+ this.offset = 0;
|
|
|
this.playbackRate = 1;
|
|
|
this.isPlaying = false;
|
|
|
this.hasPlaybackControl = true;
|
|
@@ -84,7 +85,8 @@ Audio.prototype = Object.assign( Object.create( Object3D.prototype ), {
|
|
|
source.loop = this.loop;
|
|
|
source.onended = this.onEnded.bind( this );
|
|
|
source.playbackRate.setValueAtTime( this.playbackRate, this.startTime );
|
|
|
- source.start( 0, this.startTime );
|
|
|
+ this.startTime = this.context.currentTime;
|
|
|
+ source.start( this.startTime, this.offset );
|
|
|
|
|
|
this.isPlaying = true;
|
|
|
|
|
@@ -103,9 +105,13 @@ Audio.prototype = Object.assign( Object.create( Object3D.prototype ), {
|
|
|
|
|
|
}
|
|
|
|
|
|
- this.source.stop();
|
|
|
- this.startTime = this.context.currentTime;
|
|
|
- this.isPlaying = false;
|
|
|
+ if ( this.isPlaying === true ) {
|
|
|
+
|
|
|
+ this.source.stop();
|
|
|
+ this.offset += this.context.currentTime - this.startTime;
|
|
|
+ this.isPlaying = false;
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
return this;
|
|
|
|
|
@@ -121,7 +127,7 @@ Audio.prototype = Object.assign( Object.create( Object3D.prototype ), {
|
|
|
}
|
|
|
|
|
|
this.source.stop();
|
|
|
- this.startTime = 0;
|
|
|
+ this.offset = 0;
|
|
|
this.isPlaying = false;
|
|
|
|
|
|
return this;
|