From f1481df0b63c27f1417cddf8fb0c1bf12ff58b82 Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 24 Oct 2014 15:34:53 +0200 Subject: command: add vo-configured property So a client API user can know when a window is created or destroyed. Also might be useful for the OSC: it could disable itself if video is disabled. Before this commit, there were only indirect ways of detecting this. --- DOCS/man/input.rst | 5 +++++ player/command.c | 11 ++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/DOCS/man/input.rst b/DOCS/man/input.rst index 9dc1cf0ea6..cc2bd72403 100644 --- a/DOCS/man/input.rst +++ b/DOCS/man/input.rst @@ -1372,6 +1372,11 @@ Property list Note that you need to escape the ``\`` character, because the string is processed for C escape sequences before passing it to the OSD code. +``vo-configured`` + Return whether the VO is configured right now. Usually this corresponds to + whether the video window is visible. If the ``--force-window`` option is + used, this is usually always returns ``yes``. + ``audio-device-list`` Return the list of discovered audio devices. This is mostly for use with the client API, and reflects what ``--audio-device=help`` with the command diff --git a/player/command.c b/player/command.c index c2cb206a16..1109e7ac7f 100644 --- a/player/command.c +++ b/player/command.c @@ -2403,6 +2403,14 @@ static int mp_property_window_scale(void *ctx, struct m_property *prop, return M_PROPERTY_NOT_IMPLEMENTED; } +static int mp_property_vo_configured(void *ctx, struct m_property *prop, + int action, void *arg) +{ + MPContext *mpctx = ctx; + return m_property_flag_ro(action, arg, + mpctx->video_out && mpctx->video_out->config_ok); +} + static int mp_property_osd_w(void *ctx, struct m_property *prop, int action, void *arg) { @@ -3050,6 +3058,7 @@ static const struct m_property mp_properties[] = { M_PROPERTY_ALIAS("width", "video-params/w"), M_PROPERTY_ALIAS("height", "video-params/h"), {"window-scale", mp_property_window_scale}, + {"vo-configured", mp_property_vo_configured}, {"fps", mp_property_fps}, {"estimated-vf-fps", mp_property_vf_fps}, {"video-aspect", mp_property_aspect}, @@ -3132,7 +3141,7 @@ static const char *const *const mp_event_property_change[] = { "estimated-vf-fps"), E(MPV_EVENT_VIDEO_RECONFIG, "video-out-params", "video-params", "video-format", "video-codec", "video-bitrate", "dwidth", "dheight", - "width", "height", "fps", "aspect"), + "width", "height", "fps", "aspect", "vo-configured"), E(MPV_EVENT_AUDIO_RECONFIG, "audio-format", "audio-codec", "audio-bitrate", "samplerate", "channels", "audio"), E(MPV_EVENT_SEEK, "seeking"), -- cgit v1.2.3