From b553520a488e128c0eeab4e6ec116eb21dddaecd Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Mon, 7 Jun 2021 08:28:53 +0300 Subject: [PATCH] Fixed track change notification in media player. --- .../SourceFiles/window/system_media_controls_manager.cpp | 7 +++++++ .../SourceFiles/window/system_media_controls_manager.h | 1 + 2 files changed, 8 insertions(+) diff --git a/Telegram/SourceFiles/window/system_media_controls_manager.cpp b/Telegram/SourceFiles/window/system_media_controls_manager.cpp index e9039bb63a..062693aed2 100644 --- a/Telegram/SourceFiles/window/system_media_controls_manager.cpp +++ b/Telegram/SourceFiles/window/system_media_controls_manager.cpp @@ -129,6 +129,11 @@ SystemMediaControlsManager::SystemMediaControlsManager( if (!current) { return; } + if ((_lastAudioMsgId.contextId() == current.contextId()) + && (_lastAudioMsgId.audio() == current.audio()) + && (_lastAudioMsgId.type() == current.type())) { + return; + } const auto document = current.audio(); const auto &[title, performer] = Ui::Text::FormatSongNameFor(document) @@ -156,6 +161,8 @@ SystemMediaControlsManager::SystemMediaControlsManager( } else { _controls->clearThumbnail(); } + + _lastAudioMsgId = current; }, _lifetime); _controls->commandRequests( diff --git a/Telegram/SourceFiles/window/system_media_controls_manager.h b/Telegram/SourceFiles/window/system_media_controls_manager.h index 1eb8c822e7..86a519b743 100644 --- a/Telegram/SourceFiles/window/system_media_controls_manager.h +++ b/Telegram/SourceFiles/window/system_media_controls_manager.h @@ -32,6 +32,7 @@ private: const std::unique_ptr _controls; std::vector> _cachedMediaView; + AudioMsgId _lastAudioMsgId; rpl::lifetime _lifetimeDownload; rpl::lifetime _lifetime;