mirror of https://github.com/mpv-player/mpv
command: print edition title to OSD when cycling
Edition title is already exposed in demux_edition, it was just never added to the display. If no edition title exists it will fall back to the edition number.
This commit is contained in:
parent
6e82f36f92
commit
e796fe4bfc
|
@ -1042,10 +1042,18 @@ static int mp_property_edition(void *ctx, struct m_property *prop,
|
||||||
{
|
{
|
||||||
MPContext *mpctx = ctx;
|
MPContext *mpctx = ctx;
|
||||||
struct demuxer *demuxer = mpctx->demuxer;
|
struct demuxer *demuxer = mpctx->demuxer;
|
||||||
|
char *name = NULL;
|
||||||
|
|
||||||
if (action == M_PROPERTY_GET_CONSTRICTED_TYPE && demuxer) {
|
if (!demuxer)
|
||||||
if (demuxer->num_editions <= 1)
|
return mp_property_generic_option(mpctx, prop, action, arg);
|
||||||
return M_PROPERTY_UNAVAILABLE;
|
|
||||||
|
int ed = demuxer->edition;
|
||||||
|
|
||||||
|
if (demuxer->num_editions <= 1)
|
||||||
|
return M_PROPERTY_UNAVAILABLE;
|
||||||
|
|
||||||
|
switch (action) {
|
||||||
|
case M_PROPERTY_GET_CONSTRICTED_TYPE: {
|
||||||
*(struct m_option *)arg = (struct m_option){
|
*(struct m_option *)arg = (struct m_option){
|
||||||
.type = CONF_TYPE_INT,
|
.type = CONF_TYPE_INT,
|
||||||
.min = 0,
|
.min = 0,
|
||||||
|
@ -1053,8 +1061,20 @@ static int mp_property_edition(void *ctx, struct m_property *prop,
|
||||||
};
|
};
|
||||||
return M_PROPERTY_OK;
|
return M_PROPERTY_OK;
|
||||||
}
|
}
|
||||||
|
case M_PROPERTY_PRINT: {
|
||||||
return mp_property_generic_option(mpctx, prop, action, arg);
|
if (ed < 0)
|
||||||
|
return M_PROPERTY_UNAVAILABLE;
|
||||||
|
name = mp_tags_get_str(demuxer->editions[ed].metadata, "title");
|
||||||
|
if (name) {
|
||||||
|
*(char **) arg = talloc_strdup(NULL, name);
|
||||||
|
} else {
|
||||||
|
*(char **) arg = talloc_asprintf(NULL, "%d", ed + 1);
|
||||||
|
}
|
||||||
|
return M_PROPERTY_OK;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
return mp_property_generic_option(mpctx, prop, action, arg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int get_edition_entry(int item, int action, void *arg, void *ctx)
|
static int get_edition_entry(int item, int action, void *arg, void *ctx)
|
||||||
|
@ -3734,6 +3754,7 @@ static const struct property_osd_display {
|
||||||
{"hr-seek", "hr-seek"},
|
{"hr-seek", "hr-seek"},
|
||||||
{"speed", "Speed"},
|
{"speed", "Speed"},
|
||||||
{"clock", "Clock"},
|
{"clock", "Clock"},
|
||||||
|
{"edition", "Edition"},
|
||||||
// audio
|
// audio
|
||||||
{"volume", "Volume",
|
{"volume", "Volume",
|
||||||
.msg = "Volume: ${?volume:${volume}% ${?mute==yes:(Muted)}}${!volume:${volume}}",
|
.msg = "Volume: ${?volume:${volume}% ${?mute==yes:(Muted)}}${!volume:${volume}}",
|
||||||
|
|
Loading…
Reference in New Issue