Playing Audio - error: PVMFErrNotSupported (Prepare failed.: status=0x1 )December 13th, 2009
When it comes to playing sound files in android, I've found plenty of code samples that look something like this...
try{ mp = new MediaPlayer(); mp.setDataSource(somePathToAudioFile); mp.prepare(); mp.start(); }catch(Exception e){
}
But when I tried these samples I kept getting these errors...
PVMFErrNotSupported 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){ } //in this case my sound file is in the application directory... File file = new File(audioFilePath);
|
![]() RECENT ARTICLES
|
