Error playing mp3 files on Android (ioConfigChanged)

Hey gang, I am getting a pretty strange error on the Kindle Fire Phone. I am testing out the androidSoundPlayerExample and the voice sample (which is the only mp3 – the rest are wav files) seems to trigger the following error:

03-16 20:44:14.096: AudioSystem(6594): ioConfigChanged() closing unknow output! 1080

After this error happens twice (not once! it still works after one of these), the sample no longer plays when I hit the vocals button.

I searched and searched but the only reference to this error was in the following source code:

I have no idea what is going on here, but I am worried that I am not going to be able to use mp3s in my project but rather be forced into using gigantic-sized wav files.

Note that I tried this example project with both ofSoundPlayer and ofxAndroidSoundPlayer. I tried with streaming set to true and streaming set to false. I got the same behavior in all cases.

How should I proceed?

Did you try ofxAndroidVideoPlayer?

That’s interesting, I’ve never considered using the video player to play my sound files.

Unfortunately, when I try to use it my game crashes with the the on-screen error “XXX has stopped” and the log error:

[2015-03-17 10:46:48 - ofAndroidLib] Could not find ofAndroidLib.apk!

Very strange, as all day yesterday I was experimenting with ofxAndroidSoundPlayer so I was sure another ofxAndroid function would work.

Naming convention difference between Android and openFrameworks :smile:

ofxAndroidSoundPlayer uses Android’s SoundPool, which is for short .wav sound effects, where ofxAndroidVideoPlayer uses Android’s MediaPlayer, which is very good for videos and mp3s.

you should use it like that:

ofxAndroidVideoPlayer music;
music.removeTexture(); //do not forget this line for sound files

About your error; I think you need to somehow add ofAndroidLib project to your project dependencies. Maybe Project Properties -> Java Build Path -> Projects -> Add… may do the job. But i am not sure.

EDIT: The last paragraph may not be the case. I have had such errors in the past but I don’t remember how I solved.

if you set the sound player to stream it’ll also use mediaplayer internally. like: load(sound,true)

the media player though is though to be used with long sound files… if you want to play short sounds like game effects… you should be using sound pool. not sure where the error comes from though

Ah interesting, so this is similar to the streaming=false parameter in the constructor to ofSoundPlayer? I have read that on Android it toggles between different media backends but I have not looked at the source to see for sure:

What does removeTexture() do for sound files? Does it release one of the channels? I think on my hardware (Kindle Fire Phone) there is a message at startup about 128 channels.

One thing I was hoping to fix today is simply polling the play() method to see when my sound file had finally loaded (and played) but unfortunately that method returns void.

i would use ofSoundPlayer setting streaming to true, using a video player seems super hacky and will allocate a texture, pixels… that are not necessary

First, consider Arturo’s suggestion above. I don’t use sound player with streaming, hope it will work. If not, try ofxAndroidVideoPlayer.

the removeTexture() method unload the texture of the file. Thus you will not have texture not found errors in the further steps (pause-resume, etc…)

Sorry about that error, it actually has nothing to do with sound.

Ok, so I tried both of those methods – setting streaming to true and using the ofxAndroidVideoPlayer. It’s interesting, in both cases I get the following error in my log:

03-17 16:22:09.187: I/OFAPP(13367): playMusic() loading file: twind.mp3
03-17 16:22:09.197: W/SoundPool(13367): sample 2 not READY

So, even though both of those methods were supposed to use a streaming mediaplayer on the backend my error message indicates that the soundpool is being used. I wonder if is something specific to the Kindle Fire Phone? I am going to start looking at the source to see how these functions are implemented behind the scenes, because otherwise I am at a complete loss on how to load and play a sound.

Ah, whoops I am sorry it was actually not a sound pool error – even with streaming set to true I am getting the first error mentioned in this thread:

ioConfigChanged() closing unknow output! 10

The only things I can think of are:

  1. I’m not cleaning up my sound playing objects correctly
  2. I’m not calling ofSoundUpdate() in the main loop
  3. ???

Thank you for all the help, by the way!