未验证 提交 147ad007 编写于 作者: M Mr.doob 提交者: GitHub

Merge pull request #17269 from sttz/Audio-duration

Audio: Added duration property
......@@ -91,6 +91,9 @@
<h3>[property:Number offset]</h3>
<p>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*.</p>
<h3>[property:Number duration]</h3>
<p>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.</p>
<h3>[property:String source]</h3>
<p>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]().</p>
......
......@@ -17,6 +17,7 @@ export class Audio extends Object3D {
loop: boolean;
startTime: number;
offset: number;
duration: number | undefined;
playbackRate: number;
isPlaying: boolean;
hasPlaybackControl: boolean;
......
......@@ -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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册