【问题标题】:Android display only mp3 with ACTION_GET_CONTENTAndroid 仅显示带有 ACTION_GET_CONTENT 的 mp3
【发布时间】:2011-10-04 06:15:18
【问题描述】:

我正在尝试仅显示 MP3 文件:

Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("audio/mp3");
startActivityForResult(Intent.createChooser(intent, "Music File"), FIND_MUSIC);

但它最终也会列出 *.3gp 文件。我怎样才能仅限于 *.mp3 文件?

我尝试过 setType("mp3") 但 Intent 无法找到任何加载文件的应用。

【问题讨论】:

    标签: android android-intent mp3


    【解决方案1】:

    您需要传递给 setType 以仅显示 mp3 文件的正确 MIME 类型是“audio/mpeg3”。 “audio/x-mpeg3”也应该可以工作。查看这里以获取 MIME 类型的完整列表:http://reference.sitepoint.com/html/mime-types-full

    【讨论】:

      【解决方案2】:

      “audio/mpeg3”对我不起作用。 我记录了 mp3 的 mime 类型,

      mimeType = android.webkit.MimeTypeMap.getSingleton().getMimeTypeFromExtension("mp3");
              Log.e("mime:", mimeType);
      

      它是“音频/mpeg”

      【讨论】:

        猜你喜欢
        • 2012-12-11
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-03-01
        • 1970-01-01
        • 2023-02-06
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多