[SOLVED] Sound component stop method not stopping unpreloaded asset

The SoundComponent stop() method should stop all slots.

https://developer.playcanvas.com/en/api/pc.SoundComponent.html#stop

It does stop if the audio asset is set to preload.
However if the audio asset is not set to preload the sound doesn’t stop.

Here is a test project
https://playcanvas.com/project/767340/overview/sounddoesntstop

Hey @vaios - I think this is the problem I was facing with the mute button in the Star-Lord demo.

There’s a fix for this due next patch release.

2 Likes

In my test project the audio asset is about 30 seconds long and set to autoplay and loop. If I call stop after about 1 minute the audio doesn’t stop. Load must have finished, so I wondered if your fix will also fix this test case?

It’s easy to verify. Just run your scene with the latest ‘dev’ build of the engine:

https://launch.playcanvas.com/1095813?use_local_engine=https://code.playcanvas.com/playcanvas-latest.js

Seems to have resolved it. We’ll deploy the patch within the next 48 hours (assuming we don’t uncover any issues during testing).

3 Likes

That’s a cool feature!

1 Like

Indeed it is! :smile: Read more here:

https://developer.playcanvas.com/en/user-manual/scripting/custom_engine/