javaioexceptionmediametadataretriever

java.io.IOException:setdatasource failed status = 0xFFF


I am trying to get duration of .amr file by using MediaMetadataRetriever.Bur Every time I use, It give me the Error. Following Is the code to calculate the Duration. But it gives Error at SETDATASOURCE.newfile is the file i have created at runtime.

MediaMetadataRetriever mmr = new MediaMetadataRetriever();
            mmr.setDataSource(newfile.toString());
            int duration =  
Integer.parseInt(mmr.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION));


            int durSec = duration;
            durSec = durSec/1000;
            int durHour = durSec/3600;
            durSec = durSec%3600;
            int durMin = durSec/60;
            durSec = durSec%60;
            String Time = durHour+":"+durMin+":"+durSec;
            tv_duration.setText(""+Time);
            mmr.release();

Solution

  • I don't think you want "newFile.toString()" try using java.io.File.getAbsolutePath(). I'm not sure what "newFile" is so I'm grasping at this one. .toString() will use the method on the object which may not necessarily provide a concise path.