• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Audio problem in Android

C

Cundert

Guest
I'm making a game for Android, but there's a problem that's driving me crazy and I can't find any solution on the Internet. When a window appears due to get_string() or show_message(), the audio stops, even if I play new sounds. I have to restart the app if I want to fix it.

It didn't particularly bother me until I saw that it also happens when I get a notification and push it away, when I get a call, and so on. So, whenever something interrupts the game, the audio completely dies.

I've found this function, os_is_paused(), in the documents of yoyo games:
https://docs.yoyogames.com/source/dadiospice/002_reference/operating system/os_is_paused.html

It specifically says "NOTE: On mobile devices, sounds and music will be stopped when the os is paused. They will not restart again unless you specifically start them with the appropriate function.", but it doesn't say which is that function. I've tried doing the following code in a step event of an object that's always present in the game, but it doesn't work:

if (os_is_paused()){
audio_resume_all();
}

So... what should I do? What's that magical function?

Thanks! ;)
 
T

TheMatrixHasMe

Guest
Get string and show message functions are really only supposed to be used for debugging. For your audience you'll want to code overlays that get strings and show messages that don't pause the os.
 
C

Cundert

Guest
Get string and show message functions are really only supposed to be used for debugging. For your audience you'll want to code overlays that get strings and show messages that don't pause the os.
Yeah, that's why it doesn't bother me, I'm slowly changing them with in-game objects. However, pushing a notification out of the screen or getting a call also stops the audio, and that's more problematic :S
 

rIKmAN

Member
You want the game sounds to carry on playing when you get a call?

Once you've called 'audio_resume_all' have you checked if the sounds are reporting as playing and are silent, or whether they aren't really resumed at all?

You should probably add a check to see if one of the sounds is already playing, and if it is don't call 'audio_resume_all' anymore, that code you posted above is calling it every step that the OS is paused.
 
C

Cundert

Guest
You want the game sounds to carry on playing when you get a call?

Once you've called 'audio_resume_all' have you checked if the sounds are reporting as playing and are silent, or whether they aren't really resumed at all?

You should probably add a check to see if one of the sounds is already playing, and if it is don't call 'audio_resume_all' anymore, that code you posted above is calling it every step that the OS is paused.
I don't mind if the sounds stop during a call or a notification, the problem is that they don't continue playing after that unless I close the app and open it again.

I've checked what you've said and seems like the sounds are in fact playing but silent, even without the code I posted (which didn't do anything anyways), so seems like the volume of the app becomes zero, or something like that.

What I don't understand is that, according to the yoyo documents, this is something normal (as I posted, "NOTE: On mobile devices, sounds and music will be stopped when the os is paused. They will not restart again unless you specifically start them with the appropriate function."). However, I don't find that "appropiate function", which seems like would solve my problem easily, and whenever I ask someone or somewhere for help, apparently what's happening to me is something strange :S
 

Bingdom

Googledom
What you are doing is checking to see if the os is paused, then resuming it if it is paused.

Try this
Code:
if !os_is_paused() and !audio_is_playing(music) {
audio_resume_all();
}
(You don't even need os_is_paused)
Use audio_debug(true) and tell us what's happening if this doesn't fix your issue.

Anyways, os_is_paused seems almost a bit useless, unless you want a pause screen pop-up.
 
Last edited:
C

Cundert

Guest
What you are doing is checking to see if the os is paused, then resuming it if it is paused.

Try this
Code:
if !os_is_paused() and !audio_is_playing(music) {
audio_resume_all();
}
(You don't even need os_is_paused)
Use audio_debug(true) and tell us what's happening if this doesn't fix your issue.

Anyways, os_is_paused seems almost a bit useless, unless you want a pause screen pop-up.
It didn't work, so I've tried audio_debug as you said. I've never used it and I don't quite understand each number, so here's a photo:


The changes are that the last number, before the red 0, becomes 00000000 when the sound stops (if not, it just keeps changing to different numbers), and the red line where the red 0 is, which goes from left to right constantly, also stops.
Also, I've tried the function audio_is_playing(music) and it returns true, so the song is considered to be playing.
 
C

Cundert

Guest
Commenting again, since I didn't get an answer and it's been a few days. I've been trying and searching info but the issue is still there, any help? :S
 
Top