android1.5后 视频的预览图如何实现?(分不多了见谅)高手请进~~~

zhangyuehao zhangyuehao 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
先说下我要实现的功能:
以图片的方式显示某个文件中的所以视频文件,图片最好是视频文件的第一帧画面或者视频文件的某一帧。。。
我在网上找到一个方法
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;
}
但MediaMetadataRetriever在android1.0后就隐藏了,有人说MediaMetadataRetriever这个类是用JNI方式绑定,但小弟对JNI不懂,请搞人指点,或给出android1.5支持的新方法,谢谢了~~~~~~~~~~
...全文

相关推荐

评论 19
收藏 已收藏
分享
返回顶部
zhangyuehao
Android 80,490 成员 91,371 内容