Browse Source

Audio: Updated docs, d.ts and legacy.

Mr.doob 5 years ago
parent
commit
2889f7c381
4 changed files with 31 additions and 27 deletions
  1. 5 9
      docs/api/en/audio/Audio.html
  2. 3 7
      docs/api/zh/audio/Audio.html
  3. 22 9
      src/Three.Legacy.js
  4. 1 2
      src/audio/Audio.d.ts

+ 5 - 9
docs/api/en/audio/Audio.html

@@ -85,14 +85,11 @@
 		<h3>[property:Number playbackRate]</h3>
 		<p>Speed of playback. Default is *1*.</p>
 
-		<h3>[property:Number startTime]</h3>
-		<p>The time at which the sound should begin to play. Same as the *when* paramter of [link:https://developer.mozilla.org/en-US/docs/Web/API/AudioBufferSourceNode/start AudioBufferSourceNode.start](). Default is *0*.</p>
-
 		<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>
+		<p>An offset to the time within the audio buffer that playback should begin. Same as the *offset* parameter 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>
+		<p>Overrides the duration of the audio. Same as the *duration* parameter 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
@@ -150,7 +147,7 @@
 		Return the current volume.
 		</p>
 
-		<h3>[method:Audio play]()</h3>
+		<h3>[method:Audio play]( delay )</h3>
 		<p>
 		If [page:Audio.hasPlaybackControl hasPlaybackControl] is true, starts playback.
 		</p>
@@ -162,7 +159,7 @@
 
 		<h3>[method:null onEnded]()</h3>
 		<p>
-		Called automatically when playback finished. Sets If [page:Audio.isPlaying isPlaying] to false.
+		Called automatically when playback finished.
 		</p>
 
 		<h3>[method:Audio setBuffer]( audioBuffer )</h3>
@@ -229,8 +226,7 @@
 
 		<h3>[method:Audio stop]()</h3>
 		<p>
-		If [page:Audio.hasPlaybackControl hasPlaybackControl] is enabled, stops playback,
-		resets [page:Audio.startTime startTime] to *0* and sets [page:Audio.isPlaying isPlaying] to false.
+		If [page:Audio.hasPlaybackControl hasPlaybackControl] is enabled, stops playback.
 		</p>
 
 		<h2>Source</h2>

+ 3 - 7
docs/api/zh/audio/Audio.html

@@ -84,9 +84,6 @@
 		<h3>[property:AudioListener listener]</h3>
 		<p>A reference to the listener object of this audio.</p>
 
-		<h3>[property:Number startTime]</h3>
-		<p>开始播放的时间. 和[link:https://developer.mozilla.org/en-US/docs/Web/API/AudioBufferSourceNode/start AudioBufferSourceNode.start]()的*when*参数一样. 默认为 *0*.</p>
-
 		<h3>[property:Number offset]</h3>
 		<p>音频开始播放的偏移时间. 和[link:https://developer.mozilla.org/en-US/docs/Web/API/AudioBufferSourceNode/start AudioBufferSourceNode.start]()的*offset*参数一样. 默认为 *0*.</p>
 
@@ -146,7 +143,7 @@
 		返回音量.
 		</p>
 
-		<h3>[method:Audio play]()</h3>
+		<h3>[method:Audio play]( delay )</h3>
 		<p>
 		如果[page:Audio.hasPlaybackControl hasPlaybackControl]是true, 开始播放.
 		</p>
@@ -158,7 +155,7 @@
 
 		<h3>[method:null onEnded]()</h3>
 		<p>
-		播放完成后自动调用. 如果[page:Audio.isPlaying isPlaying]设置为false.
+		播放完成后自动调用.
 		</p>
 
 		<h3>[method:Audio setBuffer]( audioBuffer )</h3>
@@ -220,8 +217,7 @@
 
 		<h3>[method:Audio stop]()</h3>
 		<p>
-		如果[page:Audio.hasPlaybackControl hasPlaybackControl]是true, 停止播放,
-		重新设置[page:Audio.startTime startTime]为 *0* 和 设置 [page:Audio.isPlaying isPlaying]为false.
+		如果[page:Audio.hasPlaybackControl hasPlaybackControl]是true, 停止播放.
 		</p>
 
 		<h2>源码</h2>

+ 22 - 9
src/Three.Legacy.js

@@ -1888,19 +1888,32 @@ Object.defineProperties( WebVRManager.prototype, {
 
 //
 
-Audio.prototype.load = function ( file ) {
+Object.defineProperties( Audio.prototype, {
 
-	console.warn( 'THREE.Audio: .load has been deprecated. Use THREE.AudioLoader instead.' );
-	var scope = this;
-	var audioLoader = new AudioLoader();
-	audioLoader.load( file, function ( buffer ) {
+	load: {
+		value: function ( file ) {
 
-		scope.setBuffer( buffer );
+			console.warn( 'THREE.Audio: .load has been deprecated. Use THREE.AudioLoader instead.' );
+			var scope = this;
+			var audioLoader = new AudioLoader();
+			audioLoader.load( file, function ( buffer ) {
 
-	} );
-	return this;
+				scope.setBuffer( buffer );
 
-};
+			} );
+			return this;
+
+		}
+	},
+	startTime: {
+		set: function () {
+
+			console.warn( 'THREE.Audio: .startTime is now .play( delay ).' );
+
+		}
+	}
+
+} );
 
 AudioAnalyser.prototype.getData = function () {
 

+ 1 - 2
src/audio/Audio.d.ts

@@ -15,7 +15,6 @@ export class Audio extends Object3D {
 	buffer: null | Audio;
 	detune: number;
 	loop: boolean;
-	startTime: number;
 	offset: number;
 	duration: number | undefined;
 	playbackRate: number;
@@ -30,7 +29,7 @@ export class Audio extends Object3D {
 	setMediaElementSource( mediaElement: HTMLMediaElement ): this;
 	setMediaStreamSource( mediaStream: MediaStream ): this;
 	setBuffer( audioBuffer: AudioBuffer ): this;
-	play(): this;
+	play( delay?: number ): this;
 	onEnded(): void;
 	pause(): this;
 	stop(): this;