diff --git a/osdep/win32/smtc.cpp b/osdep/win32/smtc.cpp index 2074f857b1f09..43d75fb1c8533 100644 --- a/osdep/win32/smtc.cpp +++ b/osdep/win32/smtc.cpp @@ -321,6 +321,11 @@ static void handle_mp_event(smtc_ctx *ctx, mpv_event *event) auto &prop = *static_cast(event->data); if (!strcmp(prop.name, "time-pos") || !strcmp(prop.name, "duration")) return; + if (!strcmp(prop.name, "media-controls")) { + mp_assert(prop.format == MPV_FORMAT_FLAG); + ctx->smtc.IsEnabled(*static_cast(prop.data)); + return; + } } update_metadata(ctx->smtc, *ctx); } catch (const winrt::hresult_error& e) { @@ -394,8 +399,6 @@ static MP_THREAD_VOID win_event_loop_fn(void *arg) winrt::throw_hresult(hr); SetWindowLongPtrW(ctx.hwnd, GWLP_USERDATA, LONG_PTR(&ctx)); - smtc.IsEnabled(true); - smtc.ButtonPressed([&](const SystemMediaTransportControls &, const SystemMediaTransportControlsButtonPressedEventArgs &args) { switch (args.Button()) { @@ -506,6 +509,7 @@ static MP_THREAD_VOID mpv_event_loop_fn(void *arg) mpv_observe_property(mpv, 0, "current-tracks", MPV_FORMAT_NODE_MAP); mpv_observe_property(mpv, 0, "duration", MPV_FORMAT_INT64); mpv_observe_property(mpv, 0, "idle-active", MPV_FORMAT_FLAG); + mpv_observe_property(mpv, 0, "media-controls", MPV_FORMAT_FLAG); mpv_observe_property(mpv, 0, "media-title", MPV_FORMAT_STRING); mpv_observe_property(mpv, 0, "metadata", MPV_FORMAT_NODE_MAP); mpv_observe_property(mpv, 0, "pause", MPV_FORMAT_FLAG); diff --git a/player/main.c b/player/main.c index 23e89005e3f60..7adc91cc3d2e4 100644 --- a/player/main.c +++ b/player/main.c @@ -417,8 +417,7 @@ int mp_initialize(struct MPContext *mpctx, char **options) #endif #if HAVE_WIN32_SMTC - if (opts->media_controls) - mp_smtc_init(mp_new_client(mpctx->clients, "SystemMediaTransportControls")); + mp_smtc_init(mp_new_client(mpctx->clients, "SystemMediaTransportControls")); #endif mp_dnd_init(mp_new_client(mpctx->clients, "dnd"));