mirror of
https://github.com/mpv-player/mpv.git
synced 2026-10-17 06:50:45 +08:00
player/command: add disc-menu-active property
This commit is contained in:
@@ -1 +1,2 @@
|
||||
add `--disc-menu` option
|
||||
add `disc-menu-active` property
|
||||
|
||||
@@ -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.
|
||||
|
||||
|
||||
@@ -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},
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user