开发者

Using Eclipse, Sound is not playing fully on emulator? Sound bytes too long?

I am currently trying to make a Soundboard application for my Android.

Using Eclipse, I have successfully made buttons and coded them so that when pressed, they play .ogg sounds in the res/raw folder. All is okay.

Now, I have discovered th开发者_StackOverflow社区at any files over about 6 seconds long aren't playing fully.

Is there any way to correct this problem? I would normally just trim the files, but some of them need to be a bit longer, but none are over 50 seconds.

Thanks alot!


What is happening is the mediaPlayer.start() instruction is being called before the file has finished fully loading. Assuming you are using mediaPlayer.create(this, resid) followed by .start() there are a few things that can help. The "right" way to do it is to put the .start() instruction inside of an onPreparedListener since .create calls .onPrepared the first time, but honestly when I put that in my soundboards I got tons of crash reports, so I reverted to just using .start after .create.

I found the problem usually occurs if the sound file is very high bitrate, or if the app is installed on a slow sdcard. I use mp3's, but usually cap the bitrate at 96k and put in the app description that if the clips aren't playing fully to move the app back to internal memory and the complaints seem to have stopped.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜