1

Here is my code:

MediaMetadataRetriever metadataRetriever;
metadataRetriever = new MediaMetadataRetriever();
metadataRetriever.setDataSource(mediaFile.getAbsolutePath());

I get exception like this:

E/AndroidRuntime( 3247): Caused by: java.lang.RuntimeException: setDataSource failed: status = 0xFFFFFFED
E/AndroidRuntime( 3247):        at android.media.MediaMetadataRetriever.setDataSource(Native Method)
E/AndroidRuntime( 3247):        at android.media.MediaMetadataRetriever.setDataSource(MediaMetadataRetriever.java:70)
E/AndroidRuntime( 3247):        at com.skyworth.tvfileexplorer.utils.FileUtils.getPreview(FileUtils.java:544)
E/AndroidRuntime( 3247):        at com.skyworth.tvfileexplorer.app.folders.CardPreviewer.doInBackground(CardPreviewer.java:33)
E/AndroidRuntime( 3247):        at com.skyworth.tvfileexplorer.app.folders.CardPreviewer.doInBackground(CardPreviewer.java:13)
Chirag Savsani
  • 6,020
  • 4
  • 38
  • 74
roger
  • 9,063
  • 20
  • 72
  • 119
  • What does mediaFile.getAbsolutePath() resolve to? – William Seemann Dec 10 '14 at 17:15
  • @WilliamSeemann mediaFile.getAbsolutePath() just return the file path, for example: /storage/emulated/0/Movies/test.mp4. I think I know the problem, it is because `setDataSource` accept `Uri` as parameter instead of `file path`. But how can I get uri of a media file? – roger Dec 12 '14 at 09:41
  • setDataSource requires a protocol. Just append "file://" to the beginning of the path. – William Seemann Dec 12 '14 at 16:45
  • @WilliamSeemann yes, you are right. I do try this method many many times, then I find that android `MediaPlayer` cannot recognize my mp4 file! I just change a mp4 file, it works. But I can play the video in windows, why both mp4, one can play while the other cannot? – roger Dec 13 '14 at 02:28

1 Answers1

3

I was getting the same error when redefining the MediaMetadataRetriever a number of times. Changed this to have a single static declaration and the problem has gone away. Using 4.4.2.

dredusher
  • 31
  • 2