2016-07-11 18:05:46 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2018-01-03 10:23:14 +00:00
|
|
|
the official desktop application for the Telegram messaging service.
|
2016-07-11 18:05:46 +00:00
|
|
|
|
2018-01-03 10:23:14 +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-09-23 16:04:26 +00:00
|
|
|
|
2016-07-11 18:05:46 +00:00
|
|
|
namespace Media {
|
2017-01-24 21:24:39 +00:00
|
|
|
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
|
|
|
|
2019-03-05 11:06:54 +00:00
|
|
|
void setValueChangedCallback(Fn<void(float64,float64)> callback) {
|
2017-05-18 16:10:39 +00:00
|
|
|
_valueChanged = std::move(callback);
|
2016-09-23 16:04:26 +00:00
|
|
|
}
|
2018-06-04 15:35:11 +00:00
|
|
|
void setInLoadingStateChangedCallback(Fn<void(bool)> callback) {
|
2017-05-18 16:10:39 +00:00
|
|
|
_inLoadingStateChanged = std::move(callback);
|
2016-09-30 18:10:54 +00:00
|
|
|
}
|
2017-05-18 16:10:39 +00:00
|
|
|
void setValue(float64 value, bool animated);
|
2020-02-03 14:19:58 +00:00
|
|
|
[[nodiscard]] float64 value() const;
|
2017-05-18 16:10:39 +00:00
|
|
|
|
2019-05-31 11:45:35 +00:00
|
|
|
void updateState(
|
|
|
|
const Player::TrackState &state,
|
|
|
|
float64 loadedTillPercent = 0.);
|
2017-05-18 16:10:39 +00:00
|
|
|
void updateLoadingState(float64 progress);
|
2016-07-11 18:05:46 +00:00
|
|
|
|
2016-09-23 16:04:26 +00:00
|
|
|
private:
|
2019-03-08 12:35:04 +00:00
|
|
|
bool valueAnimationCallback(float64 now);
|
2019-05-31 11:45:35 +00:00
|
|
|
bool availableTillAnimationCallback(float64 now);
|
|
|
|
void setAvailableTill(float64 value);
|
2019-03-05 11:06:54 +00:00
|
|
|
void emitUpdatedValue();
|
2017-05-18 16:10:39 +00:00
|
|
|
|
|
|
|
// 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;
|
2019-03-05 11:06:54 +00:00
|
|
|
Fn<void(float64,float64)> _valueChanged;
|
2017-05-18 16:10:39 +00:00
|
|
|
|
|
|
|
bool _inLoadingState = false;
|
2018-06-04 15:35:11 +00:00
|
|
|
Fn<void(bool)> _inLoadingStateChanged;
|
2016-07-11 18:05:46 +00:00
|
|
|
|
|
|
|
int64 _position = 0;
|
2017-05-03 13:01:15 +00:00
|
|
|
int64 _length = 0;
|
2019-05-31 11:45:35 +00:00
|
|
|
int64 _availableTill = -1;
|
2016-07-11 18:05:46 +00:00
|
|
|
|
2016-07-12 18:04:34 +00:00
|
|
|
bool _playing = false;
|
2016-07-12 11:38:16 +00:00
|
|
|
|
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
|