Android browser media player (stagefright?) displayed media name

与世无争的帅哥 提交于 2019-12-12 09:49:16

问题


When the Android browser opens a media file it can play, the built-in (stagefright?) media player opens up to stream it. A title for this media is displayed on the player dialog, based on the URL.

The URL in this case was http://10.0.37.195/waug_mp3_128k. The media player simply uses the last part of the path as its title.

Is it possible to change the displayed title?

I have tried a Content-Disposition header, but it had no effect:

Content-Disposition: inline; filename=Some Better Title

回答1:


The short answer is no. I don't think you can change the displayed title to show something else from the server.

I believe that player is the default AudioPreview activity from the default AOSP Music app. Looking at it's source code, apparently it will simply use the last path segment of the URI for stream using the HTTP scheme (it will only query the media database for local content/files).

Here are the relevant code snippets:

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



回答2:


Try using a filename without spaces. I have seen that android has problem with spaces in filenames. It might help.

Content-Disposition: inline; filename=Some_Better_Title


来源:https://stackoverflow.com/questions/11602523/android-browser-media-player-stagefright-displayed-media-name

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!