Playing Audio - error: PVMFErrNotSupported (Prepare failed.: status=0x1 )

When it comes to playing sound files in android, I've found plenty of code samples that look something like this...



    mp = new MediaPlayer();




}catch(Exception e){




But when I tried these samples I kept getting these errors...



Prepare failed.: status=0x1


I found that instead of passing a string into mp.setDataSource(string), I could pass in a FileDescriptor to avoid these errors.  Here's a sample that worked for me (it's a few more lines of code, because you have to create a File object and a FileInputStream object in order to get the FileDescriptor object):


if(mediaPlayer != null){

mediaPlayer = new MediaPlayer();

//in this case my sound file is in the application directory...       
String audioFilePath = getFilesDir().getAbsolutePath() + File.separator + "test.mp4";
try {

    File file = new File(audioFilePath);
    FileInputStream fis = new FileInputStream(file);

} catch(FileNotFoundException e){
} catch (IllegalArgumentException e) {

} catch (IllegalStateException e) {

} catch (IOException e) {



9 Comments - Average Rating:4.22

you save my like a charm....many thanks
Rating: 5
Date Posted: January 10th, 2015

Thanks for that. I had been struggling with this for a couple of days too. My program would play a .wav file in the emulator, but not on a real Galaxy Tab. Using the above solved the problem! Cheers - K.
Rating: 5
Date Posted: July 10th, 2011

This solution does not work for streaming from a web URL. Any other ideas?
Rating: 3
Date Posted: February 16th, 2011

i tried this bt nw i m gettin failed binder transaction error ..can someone help
Rating: 2
Date Posted: January 20th, 2011

Thanks! Your solution worked.

The other solution from the comments of "mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);" didn't work for me.
Rating: 5
Date Posted: November 23rd, 2010

Thanks. That's the second thing like this that was solved by simply using a different argument type.
Rating: 5
Date Posted: October 27th, 2010

This is really weird. I had to use the following syntax to get the player to play dcf files (OMA DRM protected music)
mp.setDataSource(new MyContext(), Uri.fromFile(file));


Where MyContext is an extended class of Context.

Hope this can help others.
Rating: 5
Date Posted: September 16th, 2010

I have found that I needed to set the audio stream type. See here.

Rating: 3
Date Posted: July 22nd, 2010