Event sounds don't work on Android

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

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

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

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, :(

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

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.

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?

What's the name of the file?

sound_lose5.ogg

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

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.

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

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

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

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.

@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

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.

@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

Preloading worked! Thanks!

views:1652 update:2011/10/9 9:57:41
corona forums © 2003-2011