From d9013ede9d1dab312c8cd6483bd307b89457fb7c Mon Sep 17 00:00:00 2001 From: Bart De Vries Date: Mon, 12 Apr 2021 11:40:57 +0200 Subject: [PATCH] Fix another issue with player startup position recovery --- src/audiomanager.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/audiomanager.cpp b/src/audiomanager.cpp index fb0746e6..1d6dee00 100644 --- a/src/audiomanager.cpp +++ b/src/audiomanager.cpp @@ -149,7 +149,7 @@ void AudioManager::setEntry(Entry* entry) // Unfortunately, this will produce an audible glitch with the current // QMediaPlayer backend. d->m_player.play(); - if(!d->m_player.isSeekable()) { + if (!d->m_player.isSeekable()) { QEventLoop loop; QTimer timer; timer.setSingleShot(true); @@ -159,7 +159,16 @@ void AudioManager::setEntry(Entry* entry) qDebug() << "Starting waiting loop"; loop.exec(); } - qDebug() << "Changing position"; + if (d->m_player.mediaStatus() != QMediaPlayer::BufferedMedia) { + QEventLoop loop; + QTimer timer; + timer.setSingleShot(true); + timer.setInterval(2000); + loop.connect(&timer, SIGNAL (timeout()), &loop, SLOT (quit()) ); + loop.connect(&d->m_player, SIGNAL (mediaStatusChanged(QMediaPlayer::MediaStatus)), &loop, SLOT (quit())); + qDebug() << "Starting waiting loop on media status" << d->m_player.mediaStatus(); + loop.exec(); + } qDebug() << "Changing position"; if (startingPosition > 1000) d->m_player.setPosition(startingPosition); d->m_player.pause(); d->lockPositionSaving = false;