Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OboeAudio doesn't play music/sounds during entire first foreground session. #12

Closed
codeniko opened this issue Apr 26, 2022 · 2 comments
Closed

Comments

@codeniko
Copy link

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()
        }
    }
@barsoosayque
Copy link
Owner

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)

@barsoosayque
Copy link
Owner

barsoosayque commented May 9, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants