Android - sounds are buggy, stop playing midway, play only on random occasions when invoked

I am developing an android game with sounds. I recently updated openfl to 4.4.1.
The sounds on flash target work perfectly.
But on android they only work on some of the occasions where they should. This issue has only started after I upgraded.

What did you upgrade from?

We changed the Android OpenAL version on Lime 3.2.0, so OpenFL 4.1 and Lime 3.1 would use a different version that may work differently

Oh, and also, what device are you using, and what Android OS version?

hi sorry i should have mentioned

my last version for openfl was 3.6.1 and lime was 2.9.1 and is now the latest version

I have a nexus 5 with android 6.0.1 (with a custom rom)

What would be the correct way to do it in the new version? Currently I do something like this:

Would you mind installing OpenFL 4.1 and Lime 3.1 and seeing if those behave differently? You may need to remove the installed app from your device to test properly

Thank you :slight_smile:

The issue still maintains, the sounds only play only sometimes.

The sounds that don’t always play… are they small WAV sounds, are they really long background sounds?

they are really small, like 1 seconds max.
Also all the sounds in the project are behaving this way

Thank you for helping

Do you have any longer sounds you could try playing instead? I don’t think we have any specific issues with very short sounds, but it may help to eliminate possibilities, thanks

(also, have you tried on the desktop, Neko or C++, how does that work?)

Well, I had a music (which i accessed from the Assets.getMusic) function, and it was also playing with stutters and would randomly stop until looped again - but i removed it just before creating this post thread (out of despair :cry:)

the issue is also there on windows target

for neko, i get the following error (a game window comes up but quickly crashes):
Called from ? line 1 Called from ApplicationMain.hx line 78 Called from ApplicationMain.hx line 93 Called from lime/app/Preloader.hx line 61 Called from openfl/display/Preloader.hx line 9 Called from openfl/display/Preloader.hx line 1 Called from lime/app/Preloader.hx line 284 Called from lime/app/Event.hx line 145 Called from ApplicationMain.hx line 220 Called from ApplicationMain.hx line 281 Called from ApplicationMain.hx line 348 Called from ApplicationMain.hx line 371 Called from Main.hx line 150 Called from Main.hx line 238 Called from puzzle/Puzzle.hx line 29 Called from puzzle/Puzzle.hx line 145 Called from puzzle/Puzzle.hx line 211 Uncaught exception - Invalid call AL lib: (EE) alc_cleanup: 1 device not closed

Invalid call, is Assets.getSound returning zero, or is some other error going on?

on android, the Assets.getSound traces [object Sound]
and Assets.getSound(…).play() traces [object SoundChannel], so I guess no errors

Hang on, I’ll try compiling with -debug option to see if there is any error there

no errors when sound is invoked

okay, so I apologize for this, I forgot to set the openfl and lime versions to the ones you recommended (i only installed them at first but did not tell haxelib to use those versions)

and the sounds work fine now, thankyou

Actually, would it still be possible to play sounds smoothly in the new version?

You see, in the new version this problem (black screen if resuming app after a while on android) is fixed, but it is back now that I have downgraded

Do Android and Windows both work better in the older version, or is Windows still giving you trouble? I’m surprised Windows wasn’t working for you before

for both targets, windows and android:

for the older version: sound works fine but there is the black screen problem
for the new version: sound mostly doesn’t work, but the black screen problem is not there

(Please ignore when I said it wasn’t working earlier as I forgot to “set” the old openfl and lime versions)

I have recorded my screen when I restore my game app. As you can see there is a black screen for a while before it resumes the game.

[I can start a new thread for this problem if you want]

We moved to a different OpenAL-Soft version for all platforms in 4.2, so I am trying to decide if we need to rollback the Android version, or the version for all platforms. So Android 4.1 works better, I am surprised that 4.1 on Windows is working very different than 4.2, but if that is the case we can roll both back soon

Update (solution):
so this method (finally) solves the sound issue on the latest version of openfl 4.4.1 and lime 3.4.1:

var audioSource = new AudioSource (lime.Assets.getAudioBuffer ("sound.ogg")); ();

which i got from the openfl blog update
This method only works for ogg audio files.