Hello!I’m new to playcanvas and i am trying to handle a sound on my scene.I have insert a sound in that way
How can i pause my sound in my script ?
Hello!I’m new to playcanvas and i am trying to handle a sound on my scene.I have insert a sound in that way
How can i pause my sound in my script ?
I believe this is what you are looking for.
// pause all sounds
this.entity.sound.pause();
// pause a specific sound
this.entity.sound.pause('beep');
when i use “this.entity.sound.pause()” i get an error: Cannot read property ‘pause’ of undefined
That means that you don’t have a sound component on that entity. Perhaps you are using the wrong entity?
Can you share a link to your project?
So it looks like you have the musicButton.js
script on an Entity called musicbutton-default
which doesn’t have a Sound component.
Thank you! You helped me a lot!