Fix another issue with player startup position recovery

This commit is contained in:
Bart De Vries 2021-04-12 11:40:57 +02:00
parent 569c988962
commit d9013ede9d
1 changed files with 11 additions and 2 deletions

View File

@ -149,7 +149,7 @@ void AudioManager::setEntry(Entry* entry)
// Unfortunately, this will produce an audible glitch with the current // Unfortunately, this will produce an audible glitch with the current
// QMediaPlayer backend. // QMediaPlayer backend.
d->m_player.play(); d->m_player.play();
if(!d->m_player.isSeekable()) { if (!d->m_player.isSeekable()) {
QEventLoop loop; QEventLoop loop;
QTimer timer; QTimer timer;
timer.setSingleShot(true); timer.setSingleShot(true);
@ -159,7 +159,16 @@ void AudioManager::setEntry(Entry* entry)
qDebug() << "Starting waiting loop"; qDebug() << "Starting waiting loop";
loop.exec(); 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); if (startingPosition > 1000) d->m_player.setPosition(startingPosition);
d->m_player.pause(); d->m_player.pause();
d->lockPositionSaving = false; d->lockPositionSaving = false;