2016-07-11 18:05:46 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
|
|
|
the official desktop version of Telegram messaging app, see https://telegram.org
|
|
|
|
|
|
|
|
Telegram Desktop is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
It is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
In addition, as a special exception, the copyright holders give permission
|
|
|
|
to link the code of portions of this program with the OpenSSL library.
|
|
|
|
|
|
|
|
Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE
|
2017-01-11 18:31:31 +00:00
|
|
|
Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
|
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
|
|
|
|
2017-05-18 16:10:39 +00:00
|
|
|
void setValueChangedCallback(base::lambda<void(float64)> callback) {
|
|
|
|
_valueChanged = std::move(callback);
|
2016-09-23 16:04:26 +00:00
|
|
|
}
|
2017-05-18 16:10:39 +00:00
|
|
|
void setInLoadingStateChangedCallback(base::lambda<void(bool)> callback) {
|
|
|
|
_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;
|
|
|
|
base::lambda<void(float64)> _valueChanged;
|
|
|
|
|
|
|
|
bool _inLoadingState = false;
|
|
|
|
base::lambda<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
|