以图片的方式显示某个文件中的所以视频文件,图片最好是视频文件的第一帧画面或者视频文件的某一帧。以下的方法是我在网上找到一个方法

private Bitmap createVideoThumbnail(String filePath) {
  Bitmap bitmap = null;
  MediaMetadataRetriever retriever = new MediaMetadataRetriever();
  try {
  retriever.setMode(MediaMetadataRetriever.MODE_CAPTURE_FRAME_ONLY);
  retriever.setDataSource(filePath);
  bitmap = retriever.captureFrame();
  } catch(IllegalArgumentException ex) {
  // Assume this is a corrupt video file
  } catch (RuntimeException ex) {
  // Assume this is a corrupt video file.
  } finally {
  try {
  retriever.release();
  } catch (RuntimeException ex) {
  // Ignore failures while cleaning up.
  }
  }
  return bitmap;
  }

相关文章:

  • 2022-01-21
  • 2022-01-13
  • 2021-12-26
  • 2022-12-23
  • 2022-01-14
  • 2022-01-17
  • 2022-12-23
猜你喜欢
  • 2021-12-03
  • 2021-06-05
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-11
相关资源
相似解决方案