Babylonjs Sound issue Error while trying to play audio: engineSound, Cannot read properties of null (reading 'duration')

I have a button when i click on the button the sound is playing.
But the issue is in my local environment it is playing but in produciton it is showing this kind of issue.

babylon.js?v=4:1 Error while trying to play audio: engineSound, Cannot read properties of null (reading 'duration')

  engineSound = new BABYLON.Sound(
    "engineSound",
    config.engineSound,
    scene,
    null,
    { loop: true, autoplay: false }
  );

function playStopModelSound(action) {
  if (action === "soundReset") {
    if (engineSound.isPlaying || engineSound.isPaused) {
      isEngineSoundPlay = false;
      engineSound.stop();
    }
    return;
  }

  if (engineSound.isPlaying) {
    engineSound.pause();
  } else {
    engineSound.play();
  }
}

And in debugger I’m also getting stopped status for it

cc @docEdub. Would you be able to reproduce this with the same sound source on the playground?

I bet the path to the sound file is incorrect in your prod environemnt.

2 Likes

my assumption as well, but i can’t really tell without seeing a demo

1 Like

What is config.engineSound set to in production?

yes, That was the path issue.
I checked the path and there was versioning added at the end.
Now it is fixed.

Thanks @everyone for your response.

2 Likes