player/command: add disc-menu-active property

This commit is contained in:
Kacper Michajłow
2026-05-25 12:17:16 +02:00
parent 5713c30160
commit a5682eb2ad
4 changed files with 35 additions and 0 deletions
+1
View File
@@ -1 +1,2 @@
add `--disc-menu` option
add `disc-menu-active` property
+6
View File
@@ -2441,6 +2441,12 @@ Property list
between having no editions and a single edition, which will be reflected by
the property, although in practice it does not matter.)
``disc-menu-active``
``yes`` when the current optical-disc stream (DVD or Blu-ray) is showing
an interactive menu (a DVD menu domain, or a visible Blu-ray menu
overlay), and ``no`` otherwise. Unavailable when the currently playing
source is not an optical disc.
``chapters``
Number of chapters.
+14
View File
@@ -1134,6 +1134,19 @@ static int mp_property_current_edition(void *ctx, struct m_property *prop,
return m_property_int_ro(action, arg, demuxer->edition);
}
static int mp_property_disc_menu_active(void *ctx, struct m_property *prop,
int action, void *arg)
{
MPContext *mpctx = ctx;
struct stream *s = disc_nav_get_stream(mpctx);
if (!s)
return M_PROPERTY_UNAVAILABLE;
struct stream_nav_state st = {0};
if (stream_control(s, STREAM_CTRL_GET_NAV_STATE, &st) < 1)
return M_PROPERTY_UNAVAILABLE;
return m_property_bool_ro(action, arg, st.menu_active);
}
static int mp_property_edition(void *ctx, struct m_property *prop,
int action, void *arg)
{
@@ -4647,6 +4660,7 @@ static const struct m_property mp_properties_base[] = {
{"chapter", mp_property_chapter},
{"edition", mp_property_edition},
{"current-edition", mp_property_current_edition},
{"disc-menu-active", mp_property_disc_menu_active},
{"chapters", mp_property_chapters},
{"editions", mp_property_editions},
{"metadata", mp_property_metadata},
+14
View File
@@ -57,6 +57,10 @@ struct disc_nav_state {
// sd_lavc path. menu_selected_track remembers what we selected so we
// can deselect it again when the menu closes.
struct track *menu_selected_track;
// Last menu_active pushed through property-change notification.
bool last_menu_active;
bool menu_active_seen;
};
static struct disc_nav_state *get_state(struct MPContext *mpctx)
@@ -344,9 +348,19 @@ void disc_nav_update(struct MPContext *mpctx)
st->bd_last_change_id = 0;
st->bd_last_vo_res = (struct mp_osd_res){0};
st->menu_selected_track = NULL;
if (st->menu_active_seen && st->last_menu_active) {
st->last_menu_active = false;
mp_notify_property(mpctx, "disc-menu-active");
}
return;
}
if (!st->menu_active_seen || nav.menu_active != st->last_menu_active) {
st->menu_active_seen = true;
st->last_menu_active = nav.menu_active;
mp_notify_property(mpctx, "disc-menu-active");
}
check_async_discontinuity(mpctx, s, &nav);
sync_current_edition(mpctx, s, &nav);