[SOLVED] Handle 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
// pause a specific sound

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?

I’m using the sound entity

Should i use something else?

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!

1 Like