Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Need help resuming a sound after user comes back from home screen

Author
Message
TDavid
11
Years of Service
User Offline
Joined: 7th Feb 2013
Location:
Posted: 31st Aug 2014 17:15 Edited at: 31st Aug 2014 17:26
Hello !

I use the stable build, Tier 1, and I have a tiny issue. I use playsound() to play the music of my game (it's a wav file). My problem is that, on android, when I come back to the game from the home screen, the wav file is no longer playing.

I decided to use getsoundsplaying() to detect if my music is playing or not. If it's not playing, the function restarts it.

However, getsoundsplaying() fails to detect that the sound is not playing anymore. Therefore, my music never gets restarted.

Does anyone know a workaround for this issue ?

Have a good day.
unlikely
12
Years of Service
User Offline
Joined: 5th Mar 2012
Location: Ohio, USA
Posted: 31st Aug 2014 17:36
You can use the GetResumed() command to get when the app returns from the home screen. When this happens, restart music? (Haven't tried this myself, but supposedly should work.)
TDavid
11
Years of Service
User Offline
Joined: 7th Feb 2013
Location:
Posted: 31st Aug 2014 17:44 Edited at: 31st Aug 2014 18:18
Oh snap ! I didn't know this command existed ! Thanks a lot, I'm trying it right away !

edit: it did the trick ! I guess I need to read through the command list again. Thanks !
Naphier
14
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 31st Aug 2014 19:54
GetResumed is pretty important. You might also want to consider resetting timers on GetResumed in case the program has been in the background for a long time and the timers are nearing the end range for their variable type. Also it can be a good time to cache new ads via RequestAdvertRefresh is you're using ads.

Note that GetResumed can sometimes "stick" and continue to return a 1 even after resumed, so you may need to adjust for that. I'm not sure if it is still happening with the latest versions of AppGameKit, but I just write in a short while GetResumed = 1 sync endwhile to make sure it is cleared.

Login to post a reply

Server time is: 2024-11-25 07:33:01
Your offset time is: 2024-11-25 07:33:01