Fix directly jumping to chapter on a non-playing track

This commit is contained in:
Bart De Vries 2023-02-27 15:04:01 +01:00
parent deaf7ebbb5
commit 7dcf3c52e2
2 changed files with 13 additions and 7 deletions

View File

@ -457,10 +457,12 @@ void AudioManager::seek(qint64 position)
// if there is still a pending seek, then we simply update that pending // if there is still a pending seek, then we simply update that pending
// value, and then manually send the positionChanged signal to have the UI // value, and then manually send the positionChanged signal to have the UI
// updated // updated
if (d->m_pendingSeek != -1 && d->m_readyToPlay) { // NOTE: this can also happen while the streaming URL is still resolving, so
// we also allow seeking even when the track is not yet readyToPlay.
if (d->m_pendingSeek != -1 || !d->m_readyToPlay) {
d->m_pendingSeek = position; d->m_pendingSeek = position;
Q_EMIT positionChanged(position); Q_EMIT positionChanged(position);
} else { } else if (d->m_pendingSeek == -1 && d->m_readyToPlay) {
d->m_player.setPosition(position); d->m_player.setPosition(position);
} }
} }
@ -637,10 +639,14 @@ void AudioManager::prepareAudio(const QUrl &loadUrl)
qint64 startingPosition = d->m_entry->enclosure()->playPosition(); qint64 startingPosition = d->m_entry->enclosure()->playPosition();
qCDebug(kastsAudio) << "Changing position to" << startingPosition / 1000 << "sec"; qCDebug(kastsAudio) << "Changing position to" << startingPosition / 1000 << "sec";
if (startingPosition <= newDuration) { // if a seek is still pending then we don't set the position here
d->m_pendingSeek = startingPosition; // this can happen e.g. if a chapter marker was clicked on a non-playing entry
} else { if (d->m_pendingSeek == -1) {
d->m_pendingSeek = -1; if (startingPosition <= newDuration) {
d->m_pendingSeek = startingPosition;
} else {
d->m_pendingSeek = -1;
}
} }
// Emit positionChanged and durationChanged signals to make sure that // Emit positionChanged and durationChanged signals to make sure that

View File

@ -181,7 +181,7 @@ FocusScope {
Controls.Slider { Controls.Slider {
id: durationSlider id: durationSlider
enabled: AudioManager.entry enabled: AudioManager.entry && AudioManager.PlaybackState != AudioManager.StoppedState && AudioManager.canPlay
Layout.fillWidth: true Layout.fillWidth: true
padding: 0 padding: 0
from: 0 from: 0