Loading sound twice

I load sound using openfl.media.Sound, but really it loaded twice by howler.min. How to make a single load?

var sound:Sound = new Sound();
sound.addEventListener(Event.COMPLETE, loadSoundCompleteHandler);
sound.load(new URLRequest("music.mp3"));

It might be loading twice, because it might be preloaded as a part of openfl.Assets

Does Assets.getSound work for your file?

If you prefer to load it later, you may need to use embed="false" on your sound asset files

I moved sound file into assets folder and added this line into project.xml:

<assets path="assets/music.mp3" embed="false" />

But it loaded twice anyway at start application.

Does it load if you don’t create your own sound?

Yes, I don’t create a sound in code, and it load automatically at start application. I think, this is because that after compilation sound created in assets folder. But I don’t understand why it happend, because I wrote embed=“false”.

I’ll look into it

Okay, thanks! I hope it will be repaired.

You wouldn’t happen to have a tag like this, would you?

<assets path="assets" />

A catch-all tag like that will embed your music file, even if you have another tag that says embed="false".

I have 3 embedded folders:

<assets path="assets/fonts" embed="true"/>
<assets path="assets/xml" embed="true"/>
<assets path="assets/img" type="image" embed="true"/>

and 2 embedded files:

<assets path="assets/project_settings.json" id="project_settings.json" type="text" embed="true" />
<assets path="assets/test.mp3" embed="false"

But the file test.mp3 loaded twice at start application.

I’ve just done a number of tests, and everything is working correctly.

Would it be possible to share a sample that’s having this behavior?

Thank you

Сan you share your working result, please?

I made a new project:

openfl create project PreloaderTest

Then I replaced the “” tag with the following:

<assets path="Assets/theme.mp3" embed="false" />

“theme.mp3” came from the PiratePig sample, but I don’t think it matters what the file is.

I tested the project, but the MP3 did not load in the network tab of the debugger

openfl test html5

I created a “testfile.txt” file as well, to test one file being embedded, and one not, and added another tag

<assets path="Assets/testfile.txt" />

This loaded in during preloading, but the sound file did not.


I just tried preloading the file, and I noticed that the sound file showed up twice, as initiated by howler.js. Perhaps this is just how Howler works, and it expects that it will be cached after the first request?

I have to check it - twice loading or just a twice label.