Merge branch 'remaining-time' into 'master'

qt: Adapt remaining time according to playback speed

Closes #28280

See merge request videolan/vlc!3842
This commit is contained in:
Mohit Marathe 2024-04-28 07:10:51 +00:00
commit de5086ca80
4 changed files with 12 additions and 1 deletions

View File

@ -1741,8 +1741,11 @@ void PlayerController::updateTime(vlc_tick_t system_now, bool forceUpdate)
// Update time properties
emit timeChanged(d->m_time);
if (d->m_time != VLC_TICK_INVALID && d->m_length != VLC_TICK_INVALID)
const float playbackSpeed = getRate();
if (d->m_time != VLC_TICK_INVALID && d->m_length != VLC_TICK_INVALID) {
d->m_remainingTime = d->m_length - d->m_time;
d->m_adjustedRemainingTime = d->m_remainingTime / playbackSpeed;
}
else
d->m_remainingTime = VLC_TICK_INVALID;
emit remainingTimeChanged(d->m_remainingTime);
@ -2061,6 +2064,7 @@ PRIMITIVETYPE_GETTER(PlayerController::PlayingState, getPlayingState, m_playing_
PRIMITIVETYPE_GETTER(QString, getName, m_name)
PRIMITIVETYPE_GETTER(VLCTick, getTime, m_time)
PRIMITIVETYPE_GETTER(VLCTick, getRemainingTime, m_remainingTime)
PRIMITIVETYPE_GETTER(VLCTick, getAdjustedRemainingTime, m_adjustedRemainingTime)
PRIMITIVETYPE_GETTER(float, getPosition, m_position)
PRIMITIVETYPE_GETTER(VLCTick, getLength, m_length)
PRIMITIVETYPE_GETTER(VLCTick, getAudioDelay, m_audioDelay)

View File

@ -113,6 +113,7 @@ public:
Q_PROPERTY(VLCTick time READ getTime WRITE setTime NOTIFY timeChanged FINAL)
Q_PROPERTY(VLCTick remainingTime READ getRemainingTime NOTIFY remainingTimeChanged FINAL)
Q_PROPERTY(VLCTick adjustedRemainingTime READ getAdjustedRemainingTime NOTIFY remainingTimeChanged FINAL)
Q_PROPERTY(float position READ getPosition WRITE setPosition NOTIFY positionChanged FINAL)
Q_PROPERTY(VLCTick length READ getLength NOTIFY lengthChanged FINAL)
@ -282,6 +283,7 @@ public slots:
VLCTick getTime() const;
void setTime(VLCTick);
VLCTick getRemainingTime() const;
VLCTick getAdjustedRemainingTime() const;
float getPosition() const;
void setPosition(float);
VLCTick getLength() const;

View File

@ -79,6 +79,7 @@ public:
VLCTick m_time = 0;
VLCTick m_remainingTime = 0;
VLCTick m_adjustedRemainingTime = 0;
double m_position = 0.f;
VLCTick m_length= 0;

View File

@ -140,6 +140,10 @@ T.Pane {
anchors.fill: parent
onClicked: MainCtx.showRemainingTime = !MainCtx.showRemainingTime
}
T.ToolTip.visible: (hovered && MainCtx.showRemainingTime)
T.ToolTip.delay: VLCStyle.delayToolTipAppear
T.ToolTip.text: Player.adjustedRemainingTime.formatHMS() + ", " + Player.rate
},
SliderBar {
id: trackPositionSlider