mirror of
https://github.com/mpv-player/mpv
synced 2025-04-11 04:01:31 +00:00
player: set playlist title to media title if not set already
The playlist title only got set when it was specified in the playlist file. If there is a title after opening a file, that should also be reflected in the playlist. ref. #4780
This commit is contained in:
parent
ed5426c351
commit
048d4d8b75
@ -2789,9 +2789,10 @@ Property list
|
|||||||
entry, ``no``/false or unavailable otherwise.
|
entry, ``no``/false or unavailable otherwise.
|
||||||
|
|
||||||
``playlist/N/title``
|
``playlist/N/title``
|
||||||
Name of the Nth entry. Only available if the playlist file contains
|
Name of the Nth entry. Available if the playlist file contains
|
||||||
such fields, and only if mpv's parser supports it for the given
|
such fields and mpv's parser supports it for the given
|
||||||
playlist format.
|
playlist format, or if the playlist entry has been opened before and a
|
||||||
|
media-title other then then filename has been aquired.
|
||||||
|
|
||||||
``playlist/N/id``
|
``playlist/N/id``
|
||||||
Unique ID for this entry. This is an automatically assigned integer ID
|
Unique ID for this entry. This is an automatically assigned integer ID
|
||||||
|
@ -519,24 +519,27 @@ static int mp_property_media_title(void *ctx, struct m_property *prop,
|
|||||||
int action, void *arg)
|
int action, void *arg)
|
||||||
{
|
{
|
||||||
MPContext *mpctx = ctx;
|
MPContext *mpctx = ctx;
|
||||||
char *name = NULL;
|
const char* name = NULL;
|
||||||
if (mpctx->opts->media_title)
|
if (mpctx->opts->media_title)
|
||||||
name = mpctx->opts->media_title;
|
name = mpctx->opts->media_title;
|
||||||
if (name && name[0])
|
if ((!name || !name[0]) && mpctx->demuxer) {
|
||||||
return m_property_strdup_ro(action, arg, name);
|
|
||||||
if (mpctx->demuxer) {
|
|
||||||
name = mp_tags_get_str(mpctx->demuxer->metadata, "service_name");
|
name = mp_tags_get_str(mpctx->demuxer->metadata, "service_name");
|
||||||
if (name && name[0])
|
if (!name || !name[0]){
|
||||||
return m_property_strdup_ro(action, arg, name);
|
|
||||||
name = mp_tags_get_str(mpctx->demuxer->metadata, "title");
|
name = mp_tags_get_str(mpctx->demuxer->metadata, "title");
|
||||||
if (name && name[0])
|
if (!name || !name[0])
|
||||||
return m_property_strdup_ro(action, arg, name);
|
|
||||||
name = mp_tags_get_str(mpctx->demuxer->metadata, "icy-title");
|
name = mp_tags_get_str(mpctx->demuxer->metadata, "icy-title");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
struct playlist_entry *const pe = mpctx->playing;
|
||||||
|
if (pe) {
|
||||||
|
if (!name || !name[0]){
|
||||||
|
name = pe->title;
|
||||||
|
} else if (!pe->title) {
|
||||||
|
pe->title = talloc_strdup(pe, name);
|
||||||
|
}
|
||||||
|
}
|
||||||
if (name && name[0])
|
if (name && name[0])
|
||||||
return m_property_strdup_ro(action, arg, name);
|
return m_property_strdup_ro(action, arg, name);
|
||||||
}
|
|
||||||
if (mpctx->playing && mpctx->playing->title)
|
|
||||||
return m_property_strdup_ro(action, arg, mpctx->playing->title);
|
|
||||||
return mp_property_filename(ctx, prop, action, arg);
|
return mp_property_filename(ctx, prop, action, arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user