question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Android]For the first time on android, there's no sound.

See original GitHub issue

Issue details

For the first time on android, there was no sound, only the second time.

Reproduction steps/code

My Code:

public void playSound(String soundName) {
        if (isSound == false)
            return;
        getSound(soundName).play();
    }

 public Sound getSound(String soundName) {
        if (assets.isLoaded(soundName, Sound.class) == true) {
            return assets.get(soundName, Sound.class);
        } else {
            assets.load(soundName, Sound.class);
            assets.finishLoading();
            return assets.get(soundName, Sound.class);
        }
    }

Version of LibGDX and/or relevant dependencies

Libgdx:1.9.8 Idea:2017.2

Please select the affected platforms

  • Android

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
Tom-Skicommented, Jan 11, 2018

Unfortunately this isn’t really something that can be solved cleanly. There are a lot of issues related to this (which you can see on this tracker, and the android tracker).

The best way to avoid this problem is to simply not load on demand, load the sounds up front and then play after loading phase, not straight after.

If we try to block, other assets can be blocked entirely for huge amounts of time as android sound pool loading can get locked.

Loading state is probably the nicest way to do this, and leave the implementation up to each dev. Playing onComplete will destroy your ears if you are playing multiple sounds like this as often SoundPool seems to loads in batches.

0reactions
MrStahlfelgecommented, Aug 28, 2020

As this is a longstanding wontfix issue, I close this now.

Read more comments on GitHub >

github_iconTop Results From Across the Web

There's no sound on my Android phone. What should I do?
First thing first, you should know that there a few basic solutions you can try, just to make sure that it's not a...
Read more >
FIX- How to fix no sound coming out from android phone
Basic Sound Troubleshooting in phone – · 1- Check your phone volume – Press your volume up/down button and increase your volume. ·...
Read more >
Fix No Sound on Videos When Playing on An Android Phone!
I downloaded a video from the internet, but there's no sound every time I play it. Can someone help fix this? Why isn't...
Read more >
Android Phone Speakers Not Working? 7 Tips and Fixes to Try
Before we dive into the actual troubleshooting for why there may be no sound from your Android phone speaker, you should make sure...
Read more >
Why does my SoundPool sound not play the first time on ...
Android SoundPool really sucks. I have to int streamid = soundPool.play(sid, soundVolume, soundVolume, 0, loopVal, 1.0f); if (streamid == 0) ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found