decentraland / sdk

PM repository for SDK
Apache License 2.0
4 stars 4 forks source link

Audio Clip Behaviour #1006

Closed CarlosPolygonalMind closed 5 months ago

CarlosPolygonalMind commented 10 months ago

Issue Description:

When setting Playing to true in the pointerDown event, the sound Stops (The sound was actually playing) Even when using a conditional to only play the sound if it's not playing, Setting playing param to true will stop the sound.

SDK:

Tool:

Steps to reproduce:

  1. Create an AudioSource
  2. Use a pointer Down to set the playing param to true
  3. If you click again before the audio stops it will stop instead of setting to true

Expected behaviour:

I was expecting to play the sound only if it`s stopped, otherwise ignore it and keep playing or at least reset when setting playinf to true but not a toggle.

Current behaviour:

The playing state toogles if I set it to true

Reproduction rate:

Always

Code Snippets:

const s0_box_01 = engine.addEntity()
MeshRenderer.setBox(s0_box_01)
MeshCollider.setBox(s0_box_01)
Transform.create(s0_box_01, {
    position: { x: 3, y: 1, z: 3}
})
AudioSource.create(s0_box_01, {
    audioClipUrl: "unity_assets/AudioClips/sfx_1.mp3",
    playing: false,
    loop: false,
    volume: 1,
    pitch: 1
})
pointerEventsSystem.onPointerDown(
    {entity: s0_box_01, opts: {button: InputAction.IA_ANY, maxDistance: 8, hoverText:"Play Sound"}},
    function(cmd){
        if(cmd.button === InputAction.IA_POINTER){
            AudioSource.getMutable(s0_box_01).playing = true
        }
    }
)

Platforms:

Browser:

Environment:

Evidence:

https://github.com/decentraland/sdk/assets/98880594/94a87905-0e0e-45e7-b928-bb66229427e3

Additional Notes:

Im working with animation clips and this issue is really bad because i want the user to hear the whole audio before playing again, without the ability to stop it and I cant find a way to do that

nearnshaw commented 5 months ago

This should no longer be a problem using the new AudioSource.playSound() interface