Sound.hx:101: Error: Could not load "my music.ogg"


I have been trying to play musics in my project, but sometimes randomly when I run my project (without re-compiling) this error happens and my file could not be played.

I am using OpenFL 3.0.0-beta3 legacy, and have tried every version of lime I had. In lime legacy 2.3.1 this problem seems to be more uncommon comparing to 2.1.2, but still happened a couple of times during test.


Hmm, perhaps a file handle isn’t being closed, but this does seem unusually (you would think it either works or doesn’t)

Is there a way to deal with it? I would not want people to pull the lottery in order to listen to musics…

Bump. Anyone else having this issue?

Wasn’t able to find related things in lime legacy src. Any news?

I think we may have just fixed this recently. There were a few file handles that were leaking, so if you loaded enough files, it might have prevented you from opening valid ones. If you’re working from the source, try the latest, otherwise it will go out soon enough :wink:

Good to know! is it for lime 2 or legacy or both?

The fixes were in lime next, so either openfl next or openfl hybrid.

Oh… well good news anyways. Also there are some bugs regarding openfl hybrid, including the unstable framerate, unable to go fullscreen etc. I will wait for them to be fixed so that I will then be free of bugs :smiley: I do hope that the fix can be done for legacy too, that would be fantastic.

Bump, any news on solving this issue for legacy?

If there is a simple test that could replicate the issue, it would be great to confirm that this is resolved in Lime 2 and show were the leaks can be patched in legacy

Umm, the test to replicate the issue is to load a music file at start up, and then repeatedly run the program over and over again. If the file never fails to load for at least 35 times then I think that will count as resolved

Bump. Anyone can look into the file handle in legacy?

Can you tell if this occurs specifically with music or sound types, or with OGG or with WAV?

My files are in .ogg, and I used both getSound and getMusic and they both have problem. Haven’t tried with wav tho.

I just walked through the legacy code, and found places where there could be unclosed file pointers. I’m not sure if this is the cause of the problems you have had, but maybe it’s worth trying?

If this doesn’t do it, perhaps we can dig more and find the code path that is having trouble, still.

The paths I found were in the file loading code, like if it was trying to read a file that it did not detect to be a WAV or OGG file, otherwise, it looks like if you do type “music” and the sound channel is not stopped, it could end up not cleaning up the file handle, either. I have not tried looking to see if stop is called automatically at the end or not. Does it matter if you play the sound for the problem to occur? Does it happen just by loading it?

If it only seem to occur when playing, you might try editing this file:

Try adding something like stop (); or lime_sound_channel_stop (__handle); in here, to be more aggressive about cleanup

The problem only seems to happen during loading. Then if it wasn’t loaded properly the music can not be played. If it loaded properly then playing it has no problem. I 'll try the first PR asap.

I know this bug too. Sound won’t play at start. Exit. Run again. Chances 50:50 :wink:
It only occurs with playMusic. Have you tried to delay loading/playing the sound some seconds, so it won’t be called directly at the start? Just an Idea.