Export to GitHub

libgdx - issue #855

sound.play() and then .setLooping() doesn't loop on Android, but sound.loop() does


Posted on May 21, 2012 by Swift Bear

Similar to http://code.google.com/p/libgdx/issues/detail?id=552

Plays, loops, works: sound.loop();

Plays only once on Android and outputs an error (works on Desktop): long soundId = sound.play(); sound.setLooping(soundId, true);

Error: E/AudioTrack(8917): setLoop invalid value: loopStart 0, loopEnd 13278, loopCount -1, framecount 3904, user 3904

Comment #1

Posted on May 24, 2012 by Massive Horse

I can not reproduce this issue? Which version are you using?

Two known problems with Sound: - samples can not be bigger than 1mb when uncompressed from the storage format (mp3, ogg). Nothing we can do about that, it's a system limitation. - samples take some time to load asynchronously due to the way Android's SoundPool works. If you load and play immediately, chances are that the first play will fail with "sample X is not READY". Again, there's not a lot we can do about.

Comment #2

Posted on May 25, 2012 by Swift Bear

I am using libgdx-nightly-20120521, but this also happened in the latest stable (0.9.3). The file I'm trying to loop is a wav. It's this wav: https://bitbucket.org/code6/multiplayerspacegame/src/f50c56b61e65/MultiplayerSpaceGame/data/accel.wav

I just tested again, and I'm getting the same result as above. In fact, if you want to see this yourself, the game I'm working on is open source: https://bitbucket.org/code6/multiplayerspacegame

If you replace line 27 in https://bitbucket.org/code6/multiplayerspacegame/src/f50c56b61e65/MultiplayerSpaceGame/src/com/puchisoft/multiplayerspacegame/GameSounds.java with "long soundId = sound.play(); sound.setLooping(soundId, true);", it will continue to loop properly on desktop, but on Android, it will only play once.

The sound is played in game when you accelerate (Tap "Host", and then W key on Desktop, or dragging on Android to accelerate).

Not a big deal. I actually prefer the .loop(), but some tutorial didn't point it out, so it took me a bit to find this workaround. Thanks for the response!

Status: WontFix

Labels:
Type-Defect Priority-Medium