RuntimeException:setDataSource 失败:status = 0x80000000 使用 MediaMetaDataRetreiver

RuntimeException: setDataSource failed: status = 0x80000000 using MediaMetaDataRetreiver

我正在尝试在 android 上制作 gif 应用程序。 GIF 制作并保存在 ExternalStoragePublicDirectory 中。现在我试图通过将文件传递给适配器来获取这些文件并使用 MediaMetadataReteiver 在 recyclerview 中显示它。下面是 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();
}

它给我 RuntimeException: setDataSource failed: status = 0x80000000。 我尝试使用包含视频文件的不同目录。它起作用了,我得到了要显示的框架。但是当我将它与 gif 一起使用时,它会给我运行时异常。我应该怎么做才能显示 gif。谢谢!

使用 Glide 显示 Gif。它将为您处理 gif 和图片

https://github.com/bumptech/glide