mirror of
https://github.com/vale981/tdesktop
synced 2025-03-06 10:11:41 -05:00
Disabling playback seeking in new media player when loading audio.
This commit is contained in:
parent
1b54ccb59c
commit
acbaf83442
4 changed files with 18 additions and 2 deletions
|
@ -195,10 +195,12 @@ void CoverWidget::updateTimeText(const AudioMsgId &audioId, const AudioPlaybackS
|
|||
if (duration || !audioId.audio()->loading()) {
|
||||
display = display / frequency;
|
||||
_time = formatDurationText(display);
|
||||
_playback->setDisabled(false);
|
||||
} else {
|
||||
auto loaded = audioId.audio()->loadOffset();
|
||||
auto loadProgress = snap(float64(loaded) / qMax(audioId.audio()->size, 1), 0., 1.);
|
||||
_time = QString::number(qRound(loadProgress * 100)) + '%';
|
||||
_playback->setDisabled(true);
|
||||
}
|
||||
if (_seekPositionMs < 0) {
|
||||
updateTimeLabel();
|
||||
|
|
|
@ -63,6 +63,9 @@ public:
|
|||
void resize(int w, int h) {
|
||||
_slider->resize(w, h);
|
||||
}
|
||||
void setDisabled(bool disabled) {
|
||||
_slider->setDisabled(disabled);
|
||||
}
|
||||
|
||||
private:
|
||||
Ui::MediaSlider *_slider;
|
||||
|
|
|
@ -35,6 +35,14 @@ float64 MediaSlider::value() const {
|
|||
return a_value.current();
|
||||
}
|
||||
|
||||
void MediaSlider::setDisabled(bool disabled) {
|
||||
if (_disabled != disabled) {
|
||||
_disabled = disabled;
|
||||
setCursor(_disabled ? style::cur_default : style::cur_pointer);
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
void MediaSlider::setValue(float64 value, bool animated) {
|
||||
if (animated) {
|
||||
a_value.start(value);
|
||||
|
@ -84,7 +92,7 @@ void MediaSlider::paintEvent(QPaintEvent *e) {
|
|||
int skip = lineLeft();
|
||||
int length = lineWidth();
|
||||
float64 prg = _mouseDown ? _downValue : a_value.current();
|
||||
int32 from = skip, mid = qRound(from + prg * length), end = from + length;
|
||||
int32 from = skip, mid = _disabled ? 0 : qRound(from + prg * length), end = from + length;
|
||||
if (mid > from) {
|
||||
p.setClipRect(0, 0, mid, height());
|
||||
p.setOpacity(_fadeOpacity * (over * _st.activeOpacity + (1. - over) * _st.inactiveOpacity));
|
||||
|
@ -97,7 +105,7 @@ void MediaSlider::paintEvent(QPaintEvent *e) {
|
|||
p.setBrush(_st.inactiveFg);
|
||||
p.drawRoundedRect(mid - radius, (height() - _st.width) / 2, end - (mid - radius), _st.width, radius, radius);
|
||||
}
|
||||
if (over > 0) {
|
||||
if (!_disabled && over > 0) {
|
||||
int x = mid - skip;
|
||||
p.setClipRect(rect());
|
||||
p.setOpacity(_fadeOpacity * _st.activeOpacity);
|
||||
|
|
|
@ -33,6 +33,7 @@ public:
|
|||
float64 value() const;
|
||||
void setValue(float64 value, bool animated);
|
||||
void setFadeOpacity(float64 opacity);
|
||||
void setDisabled(bool disabled);
|
||||
|
||||
using Callback = base::lambda_unique<void(float64)>;
|
||||
void setChangeProgressCallback(Callback &&callback) {
|
||||
|
@ -60,6 +61,8 @@ private:
|
|||
|
||||
const style::MediaSlider &_st;
|
||||
|
||||
bool _disabled = false;
|
||||
|
||||
Callback _changeProgressCallback;
|
||||
Callback _changeFinishedCallback;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue