tdesktop/Telegram/SourceFiles/media/view/media_view_playback_progress.h

63 lines
1.6 KiB
C
Raw Normal View History

2016-07-11 18:05:46 +00:00
/*
This file is part of Telegram Desktop,
the official desktop application for the Telegram messaging service.
2016-07-11 18:05:46 +00:00
For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
2016-07-11 18:05:46 +00:00
*/
#pragma once
2016-11-22 09:48:13 +00:00
#include "ui/widgets/continuous_sliders.h"
2016-07-11 18:05:46 +00:00
namespace Media {
namespace Player {
struct TrackState;
} // namespace Player
2019-02-27 11:36:19 +00:00
namespace View {
2016-07-11 18:05:46 +00:00
2019-02-27 11:36:19 +00:00
class PlaybackProgress {
2016-07-11 18:05:46 +00:00
public:
2019-02-27 11:36:19 +00:00
PlaybackProgress();
2016-07-11 18:05:46 +00:00
void setValueChangedCallback(Fn<void(float64,float64)> callback) {
_valueChanged = std::move(callback);
}
void setInLoadingStateChangedCallback(Fn<void(bool)> callback) {
_inLoadingStateChanged = std::move(callback);
}
void setValue(float64 value, bool animated);
2020-02-03 14:19:58 +00:00
[[nodiscard]] float64 value() const;
2019-05-31 11:45:35 +00:00
void updateState(
const Player::TrackState &state,
float64 loadedTillPercent = 0.);
void updateLoadingState(float64 progress);
2016-07-11 18:05:46 +00:00
private:
bool valueAnimationCallback(float64 now);
2019-05-31 11:45:35 +00:00
bool availableTillAnimationCallback(float64 now);
void setAvailableTill(float64 value);
void emitUpdatedValue();
// This can animate for a very long time (like in music playing),
2019-03-07 11:35:28 +00:00
// so it should be a Basic, not a Simple animation, because
// Simple-s pauses mtproto responses/updates handling while playing.
2019-05-31 11:45:35 +00:00
anim::value a_value, a_availableTill;
Ui::Animations::Basic _valueAnimation, _availableTillAnimation;
Fn<void(float64,float64)> _valueChanged;
bool _inLoadingState = false;
Fn<void(bool)> _inLoadingStateChanged;
2016-07-11 18:05:46 +00:00
int64 _position = 0;
int64 _length = 0;
2019-05-31 11:45:35 +00:00
int64 _availableTill = -1;
2016-07-11 18:05:46 +00:00
bool _playing = false;
2016-07-11 18:05:46 +00:00
};
2019-02-27 11:36:19 +00:00
} // namespace View
2016-07-11 18:05:46 +00:00
} // namespace Media