Android 浏览器媒体播放器(stagefright?)显示的媒体名称

标签 android android-mediaplayer android-browser content-disposition stagefright

当 Android 浏览器打开它可以播放的媒体文件时,内置的(stagefright?)媒体播放器会打开并播放它。该媒体的标题根据 URL 显示在播放器对话框中。

Android Media Player, with title highlighted

本例中的 URL 是 http://10.0.37.195/waug_mp3_128k。媒体播放器仅使用路径的最后一部分作为其标题。

是否可以更改显示的标题?

我试过 Content-Disposition header ,但没有效果:

Content-Disposition: inline; filename=Some Better Title

最佳答案

简短的回答是否定的。我不认为您可以更改显示的标题以显示来自服务器的其他内容。

我相信播放器是默认的AudioPreview来自默认 AOSP 音乐应用程序的 Activity 。查看它的源代码,显然它会简单地使用 URI 的最后一个路径段用于使用 HTTP 方案的流(它只会查询媒体数据库以获取本地内容/文件)。

以下是相关的代码 fragment :

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);

    // ...

    if (scheme.equals(ContentResolver.SCHEME_CONTENT)) {

        // ...

    } else if (scheme.equals("file")) {

        // ...

    } else {
        // We can't get metadata from the file/stream itself yet, because
        // that API is hidden, so instead we display the URI being played
        if (mPlayer.isPrepared()) {
            setNames();
        }
    }
}

// ...

public void setNames() {
    if (TextUtils.isEmpty(mTextLine1.getText())) {
        mTextLine1.setText(mUri.getLastPathSegment());
    }
    if (TextUtils.isEmpty(mTextLine2.getText())) {
        mTextLine2.setVisibility(View.GONE);
    } else {
        mTextLine2.setVisibility(View.VISIBLE);
    }
}

关于Android 浏览器媒体播放器(stagefright?)显示的媒体名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11602523/

相关文章:

安卓 android.view.WindowManager$BadTokenException : Unable to add window

Android FragmentTransaction 不会向容器添加或替换 fragment

android - Dagger 柄 : cannot be provided without an @Provides-annotated method

android - 在 xamarin android 中找不到 MEDIA_INFO_BUFFERING_START?

html - 可点击区域与 div 的显示不对齐?

javascript - 如何在安卓浏览器中制作滚动条

android - 我如何以编程方式检索 android 上的导航历史记录?

Android-测试设备的 Mediaplayer 流媒体问题

android - MediaPlayer 在调用 onStop() 时抛出 IllegalStateException

javascript - addthis_widget.js 在 Android 和 Chrome 上抛出 Cannot read property '_pmh' of null 错误