mirror of
https://github.com/vale981/tdesktop
synced 2025-03-06 18:21:42 -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()) {
|
if (duration || !audioId.audio()->loading()) {
|
||||||
display = display / frequency;
|
display = display / frequency;
|
||||||
_time = formatDurationText(display);
|
_time = formatDurationText(display);
|
||||||
|
_playback->setDisabled(false);
|
||||||
} else {
|
} else {
|
||||||
auto loaded = audioId.audio()->loadOffset();
|
auto loaded = audioId.audio()->loadOffset();
|
||||||
auto loadProgress = snap(float64(loaded) / qMax(audioId.audio()->size, 1), 0., 1.);
|
auto loadProgress = snap(float64(loaded) / qMax(audioId.audio()->size, 1), 0., 1.);
|
||||||
_time = QString::number(qRound(loadProgress * 100)) + '%';
|
_time = QString::number(qRound(loadProgress * 100)) + '%';
|
||||||
|
_playback->setDisabled(true);
|
||||||
}
|
}
|
||||||
if (_seekPositionMs < 0) {
|
if (_seekPositionMs < 0) {
|
||||||
updateTimeLabel();
|
updateTimeLabel();
|
||||||
|
|
|
@ -63,6 +63,9 @@ public:
|
||||||
void resize(int w, int h) {
|
void resize(int w, int h) {
|
||||||
_slider->resize(w, h);
|
_slider->resize(w, h);
|
||||||
}
|
}
|
||||||
|
void setDisabled(bool disabled) {
|
||||||
|
_slider->setDisabled(disabled);
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::MediaSlider *_slider;
|
Ui::MediaSlider *_slider;
|
||||||
|
|
|
@ -35,6 +35,14 @@ float64 MediaSlider::value() const {
|
||||||
return a_value.current();
|
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) {
|
void MediaSlider::setValue(float64 value, bool animated) {
|
||||||
if (animated) {
|
if (animated) {
|
||||||
a_value.start(value);
|
a_value.start(value);
|
||||||
|
@ -84,7 +92,7 @@ void MediaSlider::paintEvent(QPaintEvent *e) {
|
||||||
int skip = lineLeft();
|
int skip = lineLeft();
|
||||||
int length = lineWidth();
|
int length = lineWidth();
|
||||||
float64 prg = _mouseDown ? _downValue : a_value.current();
|
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) {
|
if (mid > from) {
|
||||||
p.setClipRect(0, 0, mid, height());
|
p.setClipRect(0, 0, mid, height());
|
||||||
p.setOpacity(_fadeOpacity * (over * _st.activeOpacity + (1. - over) * _st.inactiveOpacity));
|
p.setOpacity(_fadeOpacity * (over * _st.activeOpacity + (1. - over) * _st.inactiveOpacity));
|
||||||
|
@ -97,7 +105,7 @@ void MediaSlider::paintEvent(QPaintEvent *e) {
|
||||||
p.setBrush(_st.inactiveFg);
|
p.setBrush(_st.inactiveFg);
|
||||||
p.drawRoundedRect(mid - radius, (height() - _st.width) / 2, end - (mid - radius), _st.width, radius, radius);
|
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;
|
int x = mid - skip;
|
||||||
p.setClipRect(rect());
|
p.setClipRect(rect());
|
||||||
p.setOpacity(_fadeOpacity * _st.activeOpacity);
|
p.setOpacity(_fadeOpacity * _st.activeOpacity);
|
||||||
|
|
|
@ -33,6 +33,7 @@ public:
|
||||||
float64 value() const;
|
float64 value() const;
|
||||||
void setValue(float64 value, bool animated);
|
void setValue(float64 value, bool animated);
|
||||||
void setFadeOpacity(float64 opacity);
|
void setFadeOpacity(float64 opacity);
|
||||||
|
void setDisabled(bool disabled);
|
||||||
|
|
||||||
using Callback = base::lambda_unique<void(float64)>;
|
using Callback = base::lambda_unique<void(float64)>;
|
||||||
void setChangeProgressCallback(Callback &&callback) {
|
void setChangeProgressCallback(Callback &&callback) {
|
||||||
|
@ -60,6 +61,8 @@ private:
|
||||||
|
|
||||||
const style::MediaSlider &_st;
|
const style::MediaSlider &_st;
|
||||||
|
|
||||||
|
bool _disabled = false;
|
||||||
|
|
||||||
Callback _changeProgressCallback;
|
Callback _changeProgressCallback;
|
||||||
Callback _changeFinishedCallback;
|
Callback _changeFinishedCallback;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue