Sound isn't working on Android Phones

I’m trying to put a soundtrack into my game. The file is an .mp3. I’m using :

[lua]audio.loadSound()[/lua]

and then I’m using

[lua]audio.play()[/lua]

The sound successfully plays in the simulator but when I build it for my phone, It doesn’t play. What am I doing wrong? [import]uid: 29181 topic_id: 9384 reply_id: 309384[/import]

Hello,

I am facing the similar problem. I have integrated .mp3 file using audio.loadSound() & audio.play() methods. The sound plays fine on iPhone & iPod. But it is not working on Android device.

Which sound formats does Android support ?

I build the app using Corona 2011.288 SDK.

Thanks
[import]uid: 44599 topic_id: 9384 reply_id: 36974[/import]

One thing to check is look inside the .apk to make sure that the sound file was included correctly. If not then check your file names very carefully for upper/lowercase. Also your sound files cannot be in a subdirectory in your project, they must be at the same level as your main.lua file. [import]uid: 6787 topic_id: 9384 reply_id: 37861[/import]

Thanks for the update!

I have all the media at the same level( No sub-directory). All the file names are proper. I have double checked the file names.

Wav files are working fine. The problem is with MP3 format. [import]uid: 44599 topic_id: 9384 reply_id: 38498[/import]

You might try re-converting the file to mp3 using a different encoder. It is possible you are not using an mp3 but something else like mp4 but just have the .mp3 extension. Or it is possible you are using a variant of mp3 that our Android decoder doesn’t know about but Apple’s does.

Also, you should update your Corona simulator. 2011.288 seems old and I think we have added lots of bug fixes plus better validation alert messages since then.
[import]uid: 7563 topic_id: 9384 reply_id: 38540[/import]

android sounds sometimes work and sometimes don’t with normal file names

this may or may not work:

local winnerSound = audio.loadSound("applause.mp3")

… try appending underscore+filetype to the filename name; this works much more consistently; (ren applause.mp3 applause_mp3.mp3)

this has worked thus far:

local winnerSound = audio.loadSound("applause\_mp3.mp3")

applies to ogg and wav files as well
[import]uid: 24493 topic_id: 9384 reply_id: 39028[/import]

applause.mp3 vs. applause_mp3.mp3 is only to get around another Android limitation. You can’t have two files with the same basename or the build breaks because Android ignores the file extensions. So applause.mp3 and applause.ogg look like the same file to Android and things break.
[import]uid: 7563 topic_id: 9384 reply_id: 39036[/import]

I should reiterate that our more recent versions of the Simulators run validation tests to try to alert you (show an alert dialog) of these Android naming problems when you build for Android.
[import]uid: 7563 topic_id: 9384 reply_id: 39063[/import]