Hi everyone,
I’m working with 3d sounds of playcanvas, but I it seems to not working when I try to refresh the audio with another.
What I want to do is to play a sound when we join, then when the user clicks on a button, the event stops the current sound and play the new. And with this code, it does not stop the sound and does not play the new sound
Here is my code :
const soundElement = element.sound.slot('test');
element.sound.pause();
element.sound.stop();
if (soundElement) {
soundElement.volume = 0;
soundElement.pause();
soundElement.stop();
}
this.app.assets.loadFromUrl(url, 'audio', (error, asset) => {
if (error) console.error(error);
if (asset) {
const audio_name = 'newaudio';
try {
element.sound.addSlot(audio_name, {
asset: asset,
autoPlay: true,
loop: true,
overlap: true
});
element.sound.play(audio_name);
} catch (e) {
}
}
});
Here’s a demo : PlayCanvas | HTML5 Game Engine
Editor : PlayCanvas | HTML5 Game Engine
Did I do something wrong ?
Thanks a lot in advance and have a good day,
Corentin