diff --git a/docs/api/en/audio/Audio.html b/docs/api/en/audio/Audio.html index b739dd966ba373602b38308a2a3e5d9a4709a367..b4f91083ac7e07d09ffbd26df9f134fcd00c1a20 100644 --- a/docs/api/en/audio/Audio.html +++ b/docs/api/en/audio/Audio.html @@ -91,6 +91,9 @@

[property:Number offset]

An offset to the time within the audio buffer that playback should begin. Same as the *offset* paramter of [link:https://developer.mozilla.org/en-US/docs/Web/API/AudioBufferSourceNode/start AudioBufferSourceNode.start](). Default is *0*.

+

[property:Number duration]

+

Overrides the duration of the audio. Same as the *duration* paramter of [link:https://developer.mozilla.org/en-US/docs/Web/API/AudioBufferSourceNode/start AudioBufferSourceNode.start](). Default is *undefined* to play the whole buffer.

+

[property:String source]

An [link:https://developer.mozilla.org/en-US/docs/Web/API/AudioBufferSourceNode AudioBufferSourceNode] created using [link:https://developer.mozilla.org/en-US/docs/Web/API/AudioContext/createBufferSource AudioContext.createBufferSource]().

diff --git a/src/audio/Audio.d.ts b/src/audio/Audio.d.ts index 1edf7c8d95c08bb931181ddfb0f70d329f1fdd96..d27e56b73ef12b81e6013017a9f2b9980d16082a 100644 --- a/src/audio/Audio.d.ts +++ b/src/audio/Audio.d.ts @@ -17,6 +17,7 @@ export class Audio extends Object3D { loop: boolean; startTime: number; offset: number; + duration: number | undefined; playbackRate: number; isPlaying: boolean; hasPlaybackControl: boolean; diff --git a/src/audio/Audio.js b/src/audio/Audio.js index 35b72753543eb41cbf63f69f3f2e85ddb085f41f..6d3dd62dcc74226e5c924e1db22be5993431c3fa 100644 --- a/src/audio/Audio.js +++ b/src/audio/Audio.js @@ -24,6 +24,7 @@ function Audio( listener ) { this.loop = false; this.startTime = 0; this.offset = 0; + this.duration = undefined; this.playbackRate = 1; this.isPlaying = false; this.hasPlaybackControl = true; @@ -98,7 +99,7 @@ Audio.prototype = Object.assign( Object.create( Object3D.prototype ), { source.loop = this.loop; source.onended = this.onEnded.bind( this ); this.startTime = this.context.currentTime; - source.start( this.startTime, this.offset ); + source.start( this.startTime, this.offset, this.duration ); this.isPlaying = true;