- public Bitmap getVideoThumbnail(String filePath) {
- Bitmap bitmap = null;
- MediaMetadataRetriever retriever = new MediaMetadataRetriever();
- try {
- retriever.setDataSource(filePath);
- bitmap = retriever.getFrameAtTime();
- }
- catch(IllegalArgumentException e) {
- e.printStackTrace();
- }
- catch (RuntimeException e) {
- e.printStackTrace();
- }
- finally {
- try {
- retriever.release();
- }
- catch (RuntimeException e) {
- e.printStackTrace();
- }
- }
- return bitmap;
- }
时间: 2024-09-30 11:21:57