mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-07 23:53:58 +02:00
Added new event of seeking to media player.
This commit is contained in:
parent
b553520a48
commit
8356bac6d7
2 changed files with 27 additions and 0 deletions
|
@ -411,6 +411,16 @@ rpl::producer<> Media::Player::Instance::startsPlay(
|
||||||
}) | rpl::to_empty;
|
}) | rpl::to_empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto Media::Player::Instance::seekingChanges(AudioMsgId::Type type) const
|
||||||
|
-> rpl::producer<Media::Player::Instance::Seeking> {
|
||||||
|
return _seekingChanges.events(
|
||||||
|
) | rpl::filter([=](SeekingChanges data) {
|
||||||
|
return data.type == type;
|
||||||
|
}) | rpl::map([](SeekingChanges data) {
|
||||||
|
return data.seeking;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
not_null<Instance*> instance() {
|
not_null<Instance*> instance() {
|
||||||
Expects(SingleInstance != nullptr);
|
Expects(SingleInstance != nullptr);
|
||||||
return SingleInstance;
|
return SingleInstance;
|
||||||
|
@ -625,6 +635,7 @@ void Instance::startSeeking(AudioMsgId::Type type) {
|
||||||
}
|
}
|
||||||
pause(type);
|
pause(type);
|
||||||
emitUpdate(type);
|
emitUpdate(type);
|
||||||
|
_seekingChanges.fire({ .seeking = Seeking::Start, .type = type });
|
||||||
}
|
}
|
||||||
|
|
||||||
void Instance::finishSeeking(AudioMsgId::Type type, float64 progress) {
|
void Instance::finishSeeking(AudioMsgId::Type type, float64 progress) {
|
||||||
|
@ -643,6 +654,7 @@ void Instance::finishSeeking(AudioMsgId::Type type, float64 progress) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cancelSeeking(type);
|
cancelSeeking(type);
|
||||||
|
_seekingChanges.fire({ .seeking = Seeking::Finish, .type = type });
|
||||||
}
|
}
|
||||||
|
|
||||||
void Instance::cancelSeeking(AudioMsgId::Type type) {
|
void Instance::cancelSeeking(AudioMsgId::Type type) {
|
||||||
|
@ -650,6 +662,7 @@ void Instance::cancelSeeking(AudioMsgId::Type type) {
|
||||||
data->seeking = AudioMsgId();
|
data->seeking = AudioMsgId();
|
||||||
}
|
}
|
||||||
emitUpdate(type);
|
emitUpdate(type);
|
||||||
|
_seekingChanges.fire({ .seeking = Seeking::Cancel, .type = type });
|
||||||
}
|
}
|
||||||
|
|
||||||
void Instance::updateVoicePlaybackSpeed() {
|
void Instance::updateVoicePlaybackSpeed() {
|
||||||
|
|
|
@ -51,6 +51,12 @@ not_null<Instance*> instance();
|
||||||
|
|
||||||
class Instance : private base::Subscriber {
|
class Instance : private base::Subscriber {
|
||||||
public:
|
public:
|
||||||
|
enum class Seeking {
|
||||||
|
Start,
|
||||||
|
Finish,
|
||||||
|
Cancel,
|
||||||
|
};
|
||||||
|
|
||||||
void play(AudioMsgId::Type type);
|
void play(AudioMsgId::Type type);
|
||||||
void pause(AudioMsgId::Type type);
|
void pause(AudioMsgId::Type type);
|
||||||
void stop(AudioMsgId::Type type);
|
void stop(AudioMsgId::Type type);
|
||||||
|
@ -155,6 +161,8 @@ public:
|
||||||
rpl::producer<> stops(AudioMsgId::Type type) const;
|
rpl::producer<> stops(AudioMsgId::Type type) const;
|
||||||
rpl::producer<> startsPlay(AudioMsgId::Type type) const;
|
rpl::producer<> startsPlay(AudioMsgId::Type type) const;
|
||||||
|
|
||||||
|
rpl::producer<Seeking> seekingChanges(AudioMsgId::Type type) const;
|
||||||
|
|
||||||
bool pauseGifByRoundVideo() const;
|
bool pauseGifByRoundVideo() const;
|
||||||
|
|
||||||
void documentLoadProgress(DocumentData *document);
|
void documentLoadProgress(DocumentData *document);
|
||||||
|
@ -189,6 +197,11 @@ private:
|
||||||
std::unique_ptr<Streamed> streamed;
|
std::unique_ptr<Streamed> streamed;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct SeekingChanges {
|
||||||
|
Seeking seeking;
|
||||||
|
AudioMsgId::Type type;
|
||||||
|
};
|
||||||
|
|
||||||
Instance();
|
Instance();
|
||||||
~Instance();
|
~Instance();
|
||||||
|
|
||||||
|
@ -269,6 +282,7 @@ private:
|
||||||
rpl::event_stream<AudioMsgId::Type> _playerStopped;
|
rpl::event_stream<AudioMsgId::Type> _playerStopped;
|
||||||
rpl::event_stream<AudioMsgId::Type> _playerStartedPlay;
|
rpl::event_stream<AudioMsgId::Type> _playerStartedPlay;
|
||||||
rpl::event_stream<TrackState> _updatedNotifier;
|
rpl::event_stream<TrackState> _updatedNotifier;
|
||||||
|
rpl::event_stream<SeekingChanges> _seekingChanges;
|
||||||
rpl::lifetime _lifetime;
|
rpl::lifetime _lifetime;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue