4

I am developing a game for iOS using libGDX and Robovm; however, I need to make it possible for the user to keep background music (ipod or other apps) playing while playing the game. I added the configuration parameter allowIpod to IOSApplication:

protected IOSApplication createApplication() {
    IOSApplicationConfiguration config = new IOSApplicationConfiguration();
    config.orientationLandscape = true;
    config.orientationPortrait = false;
    config.allowIpod = true;
    return new IOSApplication(new Game(), config);
}

However, if the music was playing before starting the app, it keeps playing after opening the game. But, if I start the game, then press Home button, then play music, then return to the game, the music stops.

Has anybody encountered similar case? Any help please!

Thank you

Moh'd Al-Ahmad
  • 217
  • 2
  • 12

1 Answers1

2

According to the ObjectAL docs (which is what libGDX IOSAudio uses) you would need to set useHardwareIfAvailable to false on the OALSimpleAudio sharedInstance. This should allow you to background the app, start music, and have that music keep playing.

OALSimpleAudio.sharedInstance().setUseHardwareIfAvailable(false);

This is not currently bound in the libGDX OALSimpleAudio RoboVM bindings however, so you would need to modify the OALSimpleAudio source in the libGDX RoboVM backend to access that property. Something like (untested):

@Property(selector = "getUseHardwareIfAvailable")
public native boolean getUseHardwareIfAvailable()

@Property(selector = "setUseHardwareIfAvailable:")
public native void setUseHardwareIfAvailable(boolean b);
ericn
  • 173
  • 5