diff --git a/DOCS/man/input.rst b/DOCS/man/input.rst index ea9eb07715..7b525d7aa8 100644 --- a/DOCS/man/input.rst +++ b/DOCS/man/input.rst @@ -1349,6 +1349,9 @@ Property list ``colormatrix-primaries`` (R) See ``colormatrix``. +``taskbar-progress`` (RW) + See ``--taskbar-progress``. + ``ontop`` (RW) See ``--ontop``. diff --git a/DOCS/man/options.rst b/DOCS/man/options.rst index a4a0568f7f..ce129e3ff9 100644 --- a/DOCS/man/options.rst +++ b/DOCS/man/options.rst @@ -1794,6 +1794,12 @@ Window mode can be used to create the window always on program start, but this may cause other issues. +``--taskbar-progress``, ``--no-taskbar-progress`` + (Windows only) + Enable/disable playback progress rendering in taskbar (Windows 7 and above). + + Enabled by default. + ``--ontop`` Makes the player window stay on top of other windows. diff --git a/options/options.c b/options/options.c index 43bc2dbece..92acb42c81 100644 --- a/options/options.c +++ b/options/options.c @@ -397,6 +397,7 @@ const m_option_t mp_opts[] = { OPT_FLAG("audio-fallback-to-null", ao_null_fallback, 0), OPT_CHOICE("force-window", force_vo, 0, ({"no", 0}, {"yes", 1}, {"immediate", 2})), + OPT_FLAG("taskbar-progress", vo.taskbar_progress, 0), OPT_FLAG("ontop", vo.ontop, M_OPT_FIXED), OPT_FLAG("border", vo.border, M_OPT_FIXED), OPT_FLAG("fit-border", vo.fit_border, M_OPT_FIXED), @@ -709,6 +710,7 @@ const struct MPOpts mp_default_opts = { .panscan = 0.0f, .keepaspect = 1, .keepaspect_window = 1, + .taskbar_progress = 1, .border = 1, .fit_border = 1, .WinID = -1, diff --git a/options/options.h b/options/options.h index 6f21c0c683..5dcc642222 100644 --- a/options/options.h +++ b/options/options.h @@ -9,6 +9,7 @@ typedef struct mp_vo_opts { struct m_obj_settings *video_driver_list, *vo_defs; + int taskbar_progress; int ontop; int fullscreen; int border; diff --git a/player/command.c b/player/command.c index 66d3b6fc42..8ff2914c66 100644 --- a/player/command.c +++ b/player/command.c @@ -2409,6 +2409,23 @@ static int mp_property_fullscreen(void *ctx, struct m_property *prop, return r; } +/// Show playback progress in Windows 7+ taskbar (RW) +static int mp_property_taskbar_progress(void *ctx, struct m_property *prop, + int action, void *arg) +{ + MPContext *mpctx = ctx; + if (action == M_PROPERTY_SET) { + int desired = !!*(int *) arg; + if (mpctx->opts->vo.taskbar_progress == desired) + return M_PROPERTY_OK; + mpctx->opts->vo.taskbar_progress = desired; + if (mpctx->video_out) + update_vo_playback_state( mpctx ); + return M_PROPERTY_OK; + } + return mp_property_generic_option(mpctx, prop, action, arg); +} + /// Window always on top (RW) static int mp_property_ontop(void *ctx, struct m_property *prop, int action, void *arg) @@ -3703,6 +3720,7 @@ static const struct m_property mp_properties[] = { {"fullscreen", mp_property_fullscreen}, {"deinterlace", mp_property_deinterlace}, {"field-dominance", mp_property_generic_option}, + {"taskbar-progress", mp_property_taskbar_progress}, {"ontop", mp_property_ontop}, {"border", mp_property_border}, {"on-all-workspaces", mp_property_all_workspaces}, @@ -4036,6 +4054,7 @@ static const struct property_osd_display { { "balance", "Balance", .osd_progbar = OSD_BALANCE }, // video { "panscan", "Panscan", .osd_progbar = OSD_PANSCAN }, + { "taskbar-progress", "Progress in taskbar" }, { "ontop", "Stay on top" }, { "border", "Border" }, { "framedrop", "Framedrop" }, diff --git a/player/misc.c b/player/misc.c index f14f5a43e3..941c493cf2 100644 --- a/player/misc.c +++ b/player/misc.c @@ -116,16 +116,24 @@ void update_vo_playback_state(struct MPContext *mpctx) if (mpctx->video_out) { struct voctrl_playback_state oldstate = mpctx->vo_playback_state; struct voctrl_playback_state newstate = { + .taskbar_progress = mpctx->opts->vo.taskbar_progress, .playing = mpctx->playing, .paused = mpctx->paused, .percent_pos = get_percent_pos(mpctx), }; - if (oldstate.playing != newstate.playing || + if (oldstate.taskbar_progress != newstate.taskbar_progress || + oldstate.playing != newstate.playing || oldstate.paused != newstate.paused || - oldstate.percent_pos != newstate.percent_pos) { - vo_control(mpctx->video_out, - VOCTRL_UPDATE_PLAYBACK_STATE, &newstate); + oldstate.percent_pos != newstate.percent_pos) + { + // Don't update progress bar if it was and still is hidden + if ((oldstate.playing && oldstate.taskbar_progress) || + (newstate.playing && newstate.taskbar_progress)) + { + vo_control(mpctx->video_out, + VOCTRL_UPDATE_PLAYBACK_STATE, &newstate); + } mpctx->vo_playback_state = newstate; } } else { diff --git a/video/out/vo.h b/video/out/vo.h index 49a7546462..f6bc270afd 100644 --- a/video/out/vo.h +++ b/video/out/vo.h @@ -132,6 +132,7 @@ struct voctrl_get_equalizer_args { // VOCTRL_UPDATE_PLAYBACK_STATE struct voctrl_playback_state { + bool taskbar_progress; bool playing; bool paused; int percent_pos; diff --git a/video/out/w32_common.c b/video/out/w32_common.c index e858f037aa..28b7a7a14b 100644 --- a/video/out/w32_common.c +++ b/video/out/w32_common.c @@ -1435,7 +1435,7 @@ static int gui_thread_control(struct vo_w32_state *w32, int request, void *arg) if (!w32->taskbar_list3 || !w32->tbtnCreated) return VO_TRUE; - if (!pstate->playing) { + if (!pstate->playing || !pstate->taskbar_progress) { ITaskbarList3_SetProgressState(w32->taskbar_list3, w32->window, TBPF_NOPROGRESS); return VO_TRUE;