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