From 6472201672484e7761845cb3ddb4ead59a562df6 Mon Sep 17 00:00:00 2001 From: Rostislav Harlanov Date: Mon, 9 Sep 2024 19:38:31 +0200 Subject: [PATCH 1/4] feat: audio stop delay parameter --- src/audio/Audio.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/audio/Audio.js b/src/audio/Audio.js index cc8f6d6032cea6..ddb7fcd1a1a81b 100644 --- a/src/audio/Audio.js +++ b/src/audio/Audio.js @@ -158,7 +158,7 @@ class Audio extends Object3D { } - stop() { + stop( delay = 0 ) { if ( this.hasPlaybackControl === false ) { @@ -171,7 +171,7 @@ class Audio extends Object3D { if ( this.source !== null ) { - this.source.stop(); + this.source.stop( this.context.currentTime + this.offset + delay ); this.source.onended = null; } From 1c034e5bf937fc8f52b2a0c283aed7a2d65c5358 Mon Sep 17 00:00:00 2001 From: Rostislav Harlanov Date: Tue, 10 Sep 2024 12:21:40 +0200 Subject: [PATCH 2/4] docs: audio play/stop delay parameter --- docs/api/en/audio/Audio.html | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/api/en/audio/Audio.html b/docs/api/en/audio/Audio.html index c682b023ddda63..cde4a527247000 100644 --- a/docs/api/en/audio/Audio.html +++ b/docs/api/en/audio/Audio.html @@ -164,6 +164,7 @@

[method:Float getVolume]()

[method:this play]( delay )

+ delay (optional) - The delay, in seconds, at which the sound should start playing.
If [page:Audio.hasPlaybackControl hasPlaybackControl] is true, starts playback.

@@ -244,8 +245,9 @@

[method:this setPlaybackRate]( [param:Float value] )

[method:this setVolume]( [param:Float value] )

Set the volume.

-

[method:this stop]()

+

[method:this stop]( delay )

+ delay (optional) - The delay, in seconds, at which the sound should stop playing.
If [page:Audio.hasPlaybackControl hasPlaybackControl] is enabled, stops playback.

From 10085dc175717f1a53253185236615806bbcf184 Mon Sep 17 00:00:00 2001 From: Michael Herzog Date: Tue, 10 Sep 2024 12:48:41 +0200 Subject: [PATCH 3/4] Update Audio.html --- docs/api/en/audio/Audio.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/api/en/audio/Audio.html b/docs/api/en/audio/Audio.html index cde4a527247000..cad296b6cafdf7 100644 --- a/docs/api/en/audio/Audio.html +++ b/docs/api/en/audio/Audio.html @@ -164,7 +164,7 @@

[method:Float getVolume]()

[method:this play]( delay )

- delay (optional) - The delay, in seconds, at which the sound should start playing.
+ delay (optional) - The delay, in seconds, at which the audio should start playing.
If [page:Audio.hasPlaybackControl hasPlaybackControl] is true, starts playback.

@@ -247,7 +247,7 @@

[method:this setVolume]( [param:Float value] )

[method:this stop]( delay )

- delay (optional) - The delay, in seconds, at which the sound should stop playing.
+ delay (optional) - The delay, in seconds, at which the audio should stop playing.
If [page:Audio.hasPlaybackControl hasPlaybackControl] is enabled, stops playback.

From 7374fbdca4e1ab5ff2c37ec80c3641e0e069f9fc Mon Sep 17 00:00:00 2001 From: Rostislav Harlanov Date: Wed, 11 Sep 2024 11:50:11 +0200 Subject: [PATCH 4/4] fix: do not honor offset --- src/audio/Audio.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/audio/Audio.js b/src/audio/Audio.js index ddb7fcd1a1a81b..0b888fa79cf900 100644 --- a/src/audio/Audio.js +++ b/src/audio/Audio.js @@ -171,7 +171,7 @@ class Audio extends Object3D { if ( this.source !== null ) { - this.source.stop( this.context.currentTime + this.offset + delay ); + this.source.stop( this.context.currentTime + delay ); this.source.onended = null; }