Android browser media player (stagefright?) displayed media name
Asked Answered
G

2

3

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.

Android Media Player, with title highlighted

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
Grisgris answered 22/7, 2012 at 17:40 Comment(0)
G
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);
    }
}
Gudren answered 28/7, 2012 at 20:7 Comment(3)
Thank you for your definitive answer!Grisgris
Glad to help! Thinking about it, one thing that you can maybe try is to somehow configure the server to stream the content for http://10.0.37.195/waug_mp3_128k on something like http://10.0.37.195/waug_mp3_128k/title_to_display, or maybe even just http://10.0.37.195/title_to_display altogether :)Gudren
Yep, that's the plan. Fortunately, since I'm building the server, that part is easy.Grisgris
L
0

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
Launch answered 25/7, 2012 at 7:41 Comment(1)
Your suggestion has no effect, sorry.Grisgris

© 2022 - 2024 — McMap. All rights reserved.