[Android]For the first time on android, there's no sound.
See original GitHub issueIssue 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:
- Created 6 years ago
- Comments:5 (3 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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.
As this is a longstanding wontfix issue, I close this now.