OboeAudio doesn't play music/sounds during entire first foreground session.
Closed this issue · 2 comments
I'm using libgdx's AndroidFragmentApplication
and my game needs to play a looped background music piece as soon as the game loads. The issue is no music or sounds get played for the entire time the app is in foreground until you put app in background, and then back into foreground. Once it's in foreground for the second time, then music and sounds start playing without me having to invoke play()
on any of them. I'm using the latest libgdxoboe 0.2.4.
Not sure if this is an issue related to using AndroidFragmentApplication
instead of your README's AndroidApplication
but the fix is to invoke resume()
after creating the OboeAudio
instance. I'm assuming the issue resolves itself when you bring app back into foreground a second time because resume
gets invoked automatically. Just not that first time.
Note this wasn't something I had to do with Libgdx's default AndroidAudio.
override fun createAudio(context: Context, config: AndroidApplicationConfiguration): AndroidAudio {
return OboeAudio(context.assets).also {
it.resume()
}
}
Hmm. It's probably because of the new fragment class, yes. I need to look into that, I assume something in music lifetime changed in recent libGDX versions (and I didn't reflect those changes, as I haven't worked with libGDX in a while)
Heh, totally forgot about that 😅
Anyways, fixed in fc56d88. There were some lifetime shenanigans in the earliest days of the lib, somehow I missed the basic step of resuming the default audio engine on start. Thanks for reporting ⭐
If there are still problems, don't hesitate to reopen this issue. I've never worked with fragments, so I'm not sure if libgdx-oboe is 100% compatible with them as of now