【问题标题】:how to differentiate between 3gp audio and 3gp video如何区分 3gp 音频和 3gp 视频
【发布时间】:2013-04-26 07:52:08
【问题描述】:

我直接从内容提供商处访问视频,而不将其存储在我的数据库中。但它给了我 3gp 音频文件以及其他视频和 3gp 视频。我怎么能只过滤视频文件。我正在为 API 8 工作

【问题讨论】:

    标签: android mime-types android-contentprovider 3gp


    【解决方案1】:

    试试这个,因为您正在使用 API 8,否则如果 API 级别 >= 10,METADATA_KEY_HAS_VIDEO 可以完成这项工作。
    使用 MediaPlayer 的解决方法。如果媒体有高度,则表示它是视频。

    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;
        }
    

    Source

    【讨论】:

      猜你喜欢
      • 2013-11-01
      • 1970-01-01
      • 2011-11-22
      • 2011-06-08
      • 2021-02-11
      • 2012-02-23
      • 2011-12-16
      • 2012-01-30
      • 1970-01-01
      相关资源
      最近更新 更多