diff --git a/Telegram/SourceFiles/media/player/media_player_instance.cpp b/Telegram/SourceFiles/media/player/media_player_instance.cpp index f483ce0ece..71aa09757d 100644 --- a/Telegram/SourceFiles/media/player/media_player_instance.cpp +++ b/Telegram/SourceFiles/media/player/media_player_instance.cpp @@ -411,6 +411,16 @@ rpl::producer<> Media::Player::Instance::startsPlay( }) | rpl::to_empty; } +auto Media::Player::Instance::seekingChanges(AudioMsgId::Type type) const +-> rpl::producer { + return _seekingChanges.events( + ) | rpl::filter([=](SeekingChanges data) { + return data.type == type; + }) | rpl::map([](SeekingChanges data) { + return data.seeking; + }); +} + not_null instance() { Expects(SingleInstance != nullptr); return SingleInstance; @@ -625,6 +635,7 @@ void Instance::startSeeking(AudioMsgId::Type type) { } pause(type); emitUpdate(type); + _seekingChanges.fire({ .seeking = Seeking::Start, .type = type }); } void Instance::finishSeeking(AudioMsgId::Type type, float64 progress) { @@ -643,6 +654,7 @@ void Instance::finishSeeking(AudioMsgId::Type type, float64 progress) { } } cancelSeeking(type); + _seekingChanges.fire({ .seeking = Seeking::Finish, .type = type }); } void Instance::cancelSeeking(AudioMsgId::Type type) { @@ -650,6 +662,7 @@ void Instance::cancelSeeking(AudioMsgId::Type type) { data->seeking = AudioMsgId(); } emitUpdate(type); + _seekingChanges.fire({ .seeking = Seeking::Cancel, .type = type }); } void Instance::updateVoicePlaybackSpeed() { diff --git a/Telegram/SourceFiles/media/player/media_player_instance.h b/Telegram/SourceFiles/media/player/media_player_instance.h index 07cba2a5bb..c88054eda3 100644 --- a/Telegram/SourceFiles/media/player/media_player_instance.h +++ b/Telegram/SourceFiles/media/player/media_player_instance.h @@ -51,6 +51,12 @@ not_null instance(); class Instance : private base::Subscriber { public: + enum class Seeking { + Start, + Finish, + Cancel, + }; + void play(AudioMsgId::Type type); void pause(AudioMsgId::Type type); void stop(AudioMsgId::Type type); @@ -155,6 +161,8 @@ public: rpl::producer<> stops(AudioMsgId::Type type) const; rpl::producer<> startsPlay(AudioMsgId::Type type) const; + rpl::producer seekingChanges(AudioMsgId::Type type) const; + bool pauseGifByRoundVideo() const; void documentLoadProgress(DocumentData *document); @@ -189,6 +197,11 @@ private: std::unique_ptr streamed; }; + struct SeekingChanges { + Seeking seeking; + AudioMsgId::Type type; + }; + Instance(); ~Instance(); @@ -269,6 +282,7 @@ private: rpl::event_stream _playerStopped; rpl::event_stream _playerStartedPlay; rpl::event_stream _updatedNotifier; + rpl::event_stream _seekingChanges; rpl::lifetime _lifetime; };