Search code examples
androidgifruntimeexceptionmediametadataretriever

RuntimeException: setDataSource failed: status = 0x80000000 using MediaMetaDataRetreiver


I am trying to make a gif app on android. The gifs are made and saved in ExternalStoragePublicDirectory. Now I am trying to get those files and show it in a recyclerview using MediaMetadataReteiver by passing the files to the adapter. Below is the code in the onBindViewHolder().

Log.d("GifAdapter: ", files[position].getAbsolutePath());
try {
retriever.setDataSource(files[position].getAbsolutePath());
holder.mImageView.setImageBitmap(retriever.getFrameAtTime(1000000, OPTION_CLOSEST_SYNC));
} catch (Exception e) {
e.printStackTrace();
}

It gives me RuntimeException: setDataSource failed: status = 0x80000000. I tried using a different directory containing video files. It worked and i got the frames to display. But when i use it with gifs it gives me runtime exception. What should i do to get the gifs displayed. Thanks!


Solution

  • Use Glide to show Gifs. It will handle gifs and Images for you

    https://github.com/bumptech/glide