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
|
|
|
|
|
2016-07-11 18:05:46 +00:00
|
|
|
namespace Clip {
|
|
|
|
|
2016-09-23 16:04:26 +00:00
|
|
|
class Playback {
|
2016-07-11 18:05:46 +00:00
|
|
|
public:
|
2017-05-18 16:10:39 +00:00
|
|
|
Playback();
|
2016-07-11 18:05:46 +00:00
|
|
|
|
2018-06-04 15:35:11 +00:00
|
|
|
void setValueChangedCallback(Fn<void(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);
|
2017-05-18 17:20:07 +00:00
|
|
|
float64 value() const;
|
2017-05-24 14:36:58 +00:00
|
|
|
float64 value(TimeMs ms);
|
2017-05-18 16:10:39 +00:00
|
|
|
|
|
|
|
void updateState(const Player::TrackState &state);
|
|
|
|
void updateLoadingState(float64 progress);
|
2016-07-11 18:05:46 +00:00
|
|
|
|
2016-09-23 16:04:26 +00:00
|
|
|
private:
|
2017-05-18 16:10:39 +00:00
|
|
|
void step_value(float64 ms, bool timer);
|
|
|
|
|
|
|
|
// This can animate for a very long time (like in music playing),
|
|
|
|
// so it should be a BasicAnimation, not an Animation.
|
|
|
|
anim::value a_value;
|
|
|
|
BasicAnimation _a_value;
|
2018-06-04 15:35:11 +00:00
|
|
|
Fn<void(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;
|
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
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Clip
|
|
|
|
} // namespace Media
|