Balaji.K
Balaji.K

Reputation: 4829

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.getStartOffset(),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 ..

Upvotes: 0

Views: 2285

Answers (2)

Marco Grassi
Marco Grassi

Reputation: 1202

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.

Upvotes: 0

Andro Selva
Andro Selva

Reputation: 54322

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.

Upvotes: 1

Related Questions