Safeguard against QMediaPlayer::InvalidMedia

In case of the InvalidMedia status, skip to next track and delete the
invalid enclosure.
This commit is contained in:
Bart De Vries 2021-04-30 11:31:02 +02:00
parent 3439d1c34b
commit ead73ac2fe
1 changed files with 15 additions and 0 deletions

View File

@ -373,6 +373,21 @@ void AudioManager::mediaStatusChanged()
if (d->m_player.mediaStatus() == QMediaPlayer::EndOfMedia) {
next();
}
// if there is a problem with the current track, make sure that it's not
// loaded again when the application is restarted, skip to next track and
// delete the enclosure
if (d->m_player.mediaStatus() == QMediaPlayer::InvalidMedia) {
// save pointer to this bad entry to allow
// us to delete the enclosure after the track has been unloaded
Entry* badEntry = d->m_entry;
DataManager::instance().setLastPlayingEntry(QStringLiteral("none"));
stop();
next();
if (badEntry && badEntry->enclosure())
badEntry->enclosure()->deleteFile();
// TODO: show error overlay?
}
}
void AudioManager::playerStateChanged()