Audio files loaded by AssetsManager plays only once

I’m reading from the audio tutorial of the Babylon.JS documentation and had a section using AssetsManager and sound. I tried this and it worked - only once.

In my project the sound will need to be called again, but there is no sound.

Here’s a playground demonstrating my issue. The code follows something like this in my project, but not exactly. The reason I had this setup is that I have a game where there are multiple enemies coming on the screen and making this “sound” (not a cello onslaught, but… yeah…) and each one has their own observable something like that…?

What am I doing wrong or do I need to show more code, context, or redo the section…?

Thanks in advance, if possible…

It seems you must copy the buffer before passing it to the sound constructor, as this buffer is emptied either by the constructor or by the play method:

Actually, what I discovered is that the ArrayBuffer of the sound binary gets “consumed”. Before, the object’s ArrayBuffer would have an integer value. After it the sound plays, the ArrayBuffer would be 0, which is making the AudioBuffer object to be cleansed as well.

What I did was copied, not referenced the value using the following code:

function copyBuffer(source) {
var copy = new ArrayBuffer(source.byteLength)'
new Uint8Array(copy).set(new Uint8Array(source))
return copy

…and then used that return value of the copy value of the ArrayBuffer and play it in the Sound object.
here’s an example in this revised playground. It somehow works.

I would like to thank this StackExcahnge question for giving me that answer for anyone to take a look.