开发者

Playing the audio file in android

In my application i want to play the audio through the MediaPlayer.

My code is

AssetFileDescriptor afd = getAssets().openFd("androidprojectsound.mp3");
MediaPlayer player= new MediaPlayer();
player.setDataSource(afd.getFileDescriptor(),afd.getStart开发者_如何学COffset(),afd.getLength());
player.prepare();
player.start();

In my logcat it shows the error message like

06-13 14:23:18.247: DEBUG/AudioSink(34): bufferCount (4) is too small and increased to 12
06-13 14:23:18.755: WARN/AudioFlinger(34): write blocked for 74 msecs, 1 delayed writes, thread 0xb3d8
06-13 14:59:34.125: ERROR/MP3Extractor(34): Unable to resync. Signalling end of stream.

I don't where iam doing wrong. Any suggestion wil be appreciated ..


This means that your file is playing. You have to check it in a real Device. This is no issue. It will play fine in a Device. Try to run it in a Device.


Why don't you use play.setDataSource(FileDescriptor) instead of player.setDataSource(FileDescriptor,long,long)? From the code I've understood that you want to play the whole mp3.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜