# Audio files loaded by AssetsManager plays only once

**URL:** <https://forum.babylonjs.com/t/audio-files-loaded-by-assetsmanager-plays-only-once/20698>\
**Category:** Questions\
**Created:** [May 10, 2021, 4:46am UTC](https://forum.babylonjs.com/t/audio-files-loaded-by-assetsmanager-plays-only-once/20698 "2021-05-10T04:46:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pseudoCK](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/pseudock/32/50215_2.png) [@pseudoCK](https://forum.babylonjs.com/u/pseudoCK)\
**Post date:** [May 10, 2021, 4:46am UTC](https://forum.babylonjs.com/t/audio-files-loaded-by-assetsmanager-plays-only-once/20698/1 "2021-05-10T04:46:07Z")

</div>

I’m reading from the [audio tutorial](https://doc.babylonjs.com/divingDeeper/audio/playingSoundsMusic) 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](https://www.babylonjs-playground.com/#Y3344K) 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…

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [May 10, 2021, 10:14am UTC](https://forum.babylonjs.com/t/audio-files-loaded-by-assetsmanager-plays-only-once/20698/2 "2021-05-10T10:14:52Z")

</div>

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:

[https://www.babylonjs-playground.com/#Y3344K#3](https://www.babylonjs-playground.com/#Y3344K#3)

---

<div class="post-metadata">

**Author:** ![pseudoCK](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/pseudock/32/50215_2.png) [@pseudoCK](https://forum.babylonjs.com/u/pseudoCK)\
**Post date:** [May 11, 2021, 6:10am UTC](https://forum.babylonjs.com/t/audio-files-loaded-by-assetsmanager-plays-only-once/20698/3 "2021-05-11T06:10:50Z")

</div>

Actually, what I discovered is that the ArrayBuffer of the sound binary gets “consumed”. Before, the `BinaryFileAssetTask.data` 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](https://www.babylonjs-playground.com/#Y3344K#4). It somehow works.

I would like to thank this [StackExcahnge](https://stackoverflow.com/questions/10100798/whats-the-most-straightforward-way-to-copy-an-arraybuffer-object) question for giving me that answer for anyone to take a look.
