Event sounds don't work on Android

19 replies [Last post]
DFox
User offline. Last seen 12 hours 59 min ago. Offline
Joined: 17 May 2010

This one is easy to describe. Event sounds don't work on Android, as far as I know any format (mp3, wav).

Replies

Eric
User offline. Last seen 1 year 23 weeks ago. Offline
Joined: 23 Jun 2009

They work for me. Wav will not work, but ogg and mp3 should.

DFox
User offline. Last seen 12 hours 59 min ago. Offline
Joined: 17 May 2010

I was just using mp3 and it didn't seem to work. I'll give ogg a try and see what happens.

DFox
User offline. Last seen 12 hours 59 min ago. Offline
Joined: 17 May 2010

I haven't been able to give ogg a try because I can't build for Android right now...

I keep getting the error "An error occurred during the build. Please consult the Console logs (or the corresponding Terminal window) for more details." in the simulator and:

"2010-07-16 04:12:10.165 Corona Simulator[7188:903] Connection error: (corona.get) ({
"/kWSHTTPResponseMessage" = {url = http://developer.anscamobile.com/services/xmlrpc; status = HTTP/1.1 200 OK};"

in the terminal. If this is because work is being done on Android stuff, then great! Otherwise, :(

Eric
User offline. Last seen 1 year 23 weeks ago. Offline
Joined: 23 Jun 2009

Dunno about when you were trying, but I just did an Android build successfully.

Eric
User offline. Last seen 1 year 23 weeks ago. Offline
Joined: 23 Jun 2009

So, a little more detail on what is going on in the code. I just walked through both ogg and mp3 cases.

In the OGG case, it just works.

In the MP3 case, if I use media.playEventSound("foo.mp3"), I get messages in the log: "sample 8 not READY". This is because the mp3 decoder isn't ready by the time the sound is played. If however I use sound = media.newEventSound followed by a playEventSound( sound ), then it works fine. This gives the mp3 decoder time to catch up.

One more caveat, the Android event sound API does not have a completion listener, so the Corona event sound completion listener will never be called, if you are using that.

DFox
User offline. Last seen 12 hours 59 min ago. Offline
Joined: 17 May 2010

Thanks for the information. Sounds good.

But, I'm still not able to build for Android, and I figured out why, and it's the weirdest thing. Right after you posted about the ogg format, I set my project up to try it, and that's when I started getting that error. I couldn't figure out what was causing it, but finally, I did... It's for some reason having the ogg file in my project causes that error to occur... Taking out any and all ogg files allow it to compile again.

Any idea what's up with this?

Eric
User offline. Last seen 1 year 23 weeks ago. Offline
Joined: 23 Jun 2009

What's the name of the file?

DFox
User offline. Last seen 12 hours 59 min ago. Offline
Joined: 17 May 2010

sound_lose5.ogg

DFox
User offline. Last seen 12 hours 59 min ago. Offline
Joined: 17 May 2010

Oh yeah and if I try to build the same project for iPhone instead, it works.

Eric
User offline. Last seen 1 year 23 weeks ago. Offline
Joined: 23 Jun 2009

Ok, I took a look at the log. It looks like you have a .ogg and a .mp3 of the same name. The build script is barfing on that. Try removing or renaming one of them.

DFox
User offline. Last seen 12 hours 59 min ago. Offline
Joined: 17 May 2010

Ah, great, thanks! It works now! So does ogg sound. Thanks a ton for all the info.

Eric
User offline. Last seen 1 year 23 weeks ago. Offline
Joined: 23 Jun 2009

BTW the name collision is logged as case #199, so we will address it. It's lower priority since there is a workaround.

azone
User offline. Last seen 4 hours 20 min ago. Offline
Joined: 24 Feb 2010

I have a different problem with sounds on Android. When I play a sound many times in fast sequence it gets quiet sometimes and then doesn't play that particular sound anymore (But it does play other sounds still). And there is no error in the terminal window. It happens either in a simulator or on my Android device.

Do you know how to avoid that?

Thanks

Eric
User offline. Last seen 1 year 23 weeks ago. Offline
Joined: 23 Jun 2009

My offhand guess is that something is going wrong with the sound stream. If something happens in the wrong state, it locks up. Can you provide a code and sound sample that reproduces it? Send to support at anscamobile dot com.

Tom
User is online Online
Staff
Joined: 13 Jul 2010

@dpavlica, can you provide some sample code that demonstrates the problem (we can't seem to reproduce it)? You say this also happens in the Corona Simulator?

Thanks,
-Tom

MBD's picture
MBD
User offline. Last seen 1 hour 10 min ago. Offline
Joined: 14 Sep 2010

I am trying to build for Android 1.6 and have tried ogg, mp3, and caf - all with no luck.
They PLAY in the simulator but not on my Nexus one 2.2 device.

Tom
User is online Online
Staff
Joined: 13 Jul 2010

@MPD,

The Android only plays ogg and mp3 audio files. If you are using playEventSound, you need to preload the sound before you can play it. Have you tried the AudioPlayer in Beta8 sample code? That should work.

-Tom

MBD's picture
MBD
User offline. Last seen 1 hour 10 min ago. Offline
Joined: 14 Sep 2010

Preloading worked! Thanks!

Viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.