本文介绍了如何3GP音频和3GP视频区分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是直接从内容提供商访问的视频,而无需将其存储在我的数据库。但它给我3GP音频文件与其他视频和3GP视频一起。我怎么可能只过滤files.I我工作了8 API视频
I am accessing the videos directly from content provider without storing it in my database. But it is giving me 3gp audio file along with other video and 3gp videos. how could i filter only the video files.I am working for API 8
推荐答案
试试这个,因为你工作的API 8,否则 METADATA_KEY_HAS_VIDEO 可以做的工作,如果API级别> = 10,结果
一个解决的MediaPlayer使用。如果媒体有身高就意味着它是一个视频。
Try this since you are working on API 8, otherwise METADATA_KEY_HAS_VIDEO could have done the job if API level >= 10.
A work around using MediaPlayer. If media has height it means it is a video.
public boolean isVideoFile(File file) {
int height = 0;
try {
MediaPlayer mp = new MediaPlayer();
FileInputStream fs;
FileDescriptor fd;
fs = new FileInputStream(file);
fd = fs.getFD();
mp.setDataSource(fd);
mp.prepare();
height = mp.getVideoHeight();
mp.release();
} catch (Exception e) {
Log.e(TAG, "Exception trying to determine if 3gp file is video.", e);
}
return height > 0;
}
这篇关于如何3GP音频和3GP视频区分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!