MP3's don't work in Android

Previous topic - Next topic


At least not through "PLAYMUSIC". Just wondering why? What formats should I use then? I just bought 5 mp3 tracks for my game but I can't get them loaded up under Android.

I searched 'android mp3' and didn't see any info..


ops, replied to that somewhere else, you may want to check ogg or wav formats for that.
Lots of open programs can do yourself the proper convertion, one can be audacity.

You could also use virtual dub as it is capable to deal with encapsulators and codecs installed on your system.
Wav may cause big files, ogg is quite interesting.

Jonás Perusquía

im using .ogg for my android apps since .mp3 can´t be read by Android OS
Be free and do good things


That is great Jonaspm!

I hope it helps Falstaff, I´m going into the trouble of an android compiling quite soon, hope it helps me too! thanks :good:


Oh well wasn't really that hard TO deal with, Audacity made converting the files to .ogg a snap. Here is the code I'm using to play music so far in my game, maybe someone else would find it handy. It basically scans the media directory for any .mp3 files and then shuffles them and plays through all of them. On android it searches for .ogg files instead ;)

Just GOSUB LoadSongs to scan for the songs, then GOSUB RunMusic during your main loop to make sure the songs are looping.

Code (glbasic) Select

// --------------------------------- //
// Project: zombietest
// Start: Wednesday, May 09, 2012
// IDE Version: 10.283

GLOBAL CurrentSong%

SUB LoadSongs:

LOCAL audioext$ = ".mp3"
LOCAL files$[]

audioext$ = ".ogg"

// Grab the number of songs
LOCAL num = MOD(GETFILELIST("*" + audioext$, files$[]), 0x10000)
DIM songs$[num]

// skip 2 because '.' and '..' count
FOR i = 2 TO BOUNDS(files$[], 0) - 1

songs$[i - 2] = files$[i]
DEBUG "Found song: " + songs$[i - 2] + "\n"


GOSUB ShuffleSongs

CurrentSong = 0


SUB ShuffleSongs:

LOCAL num%
LOCAL itemAtIndex$

// Run through each song and shuffle it's order
FOR i = BOUNDS(songs$[], 0) - 1 TO 0 STEP -1

num = RND(i)
SWAP songs$[num], songs$[i]



SUB RunMusic:


INC CurrentSong
IF CurrentSong >= LEN(songs$[]) THEN CurrentSong = 0
PLAYMUSIC songs$[CurrentSong], FALSE

DEBUG "Started playing song: " + songs$[CurrentSong] + "\n"




I wrote a similar function for my game, but when it was time to play the next song, the entire game would freeze for a second while the song loads.  (They were MP3s playing on a PC)

Is there a way to preload a song at the game start?
Does your code have that problem too?
My current project (WIP) :: TwistedMaze <<  [Updated: 2015-11-25]


could the delay be an "mp3 pre-decode" thing maybe?


Well, now that you mention it.. yeah I do notice a little frame skip/stutter when the next song gets loaded. I'm not really sure there's much that can be done about it though.. I don't think you can buffer or preload things with PLAYMUSIC.


QuoteI don't think you can buffer or preload things with PLAYMUSIC.
I don't think so either.  I think this was asked before.

I wonder as Erico suggested, if this is only MP3 related?
I have no problem converting to OGG files, as I'm targeting portable devices.
Just the PC version would be a problem as not everybody has the OGG drivers installed.

I think the problem is the sound library Gernot uses.
It doesn't have a method to preload either, or something.
He is talking about moving to a new sound library (or an optional library?), so this may fix this issue.
My current project (WIP) :: TwistedMaze <<  [Updated: 2015-11-25]


Yep there is a little delay which happens on most platforms. Mightbeen the load thing should been started into a thread internally, so its would been much less notiable?

Howover its a minimal issue really and not effect my game anyway since I start the music on black screen.

Also this should been in the document. Also MacOS might require OGG too.

Just remember converting from lossy to a another lossy format can lose quality as well, so its allways best to doing directly from source. Its not allways possible, but if the mp3 was brought with 320kbit mp3, you could with no problems convert it to 128kbit ogg anyway to save filespace and quality is still nice.
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 -


Agree, It would be nice to check if other formats have this.

I was thinking about implementing something like a dynamic music on my game, similar to what Richard Joseph did on Chaos Engine, like having a few different  music loops, and seamlessly change to another music loop according to game situation.

As I currently think about it, I would also have to time the music so next loop gets in perfectly, so there should be no delays and it must be very precise. If the issue is about a pre-decoding mp3, then using wav, which I guess is a more ´uncompressed´ format, could help this out.

I think I will get to the music part in a couple weeks, if time is friendly, then I may be able to share some experiences with sound too.
If it takes longer then that, I guess I won´t be able to try this system out this turn.


If just adpcm was possible on all os i think its would been best format for short dynamic loop music. Here both ogg and mp3 came too short due gaps in endning.

Sound and/or music generally could been improvement in glbasic v11 or v12
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 -