Permalink
Browse files

MythMusic: Update the track length to match the actual play time.

TabLib has problems with calculating the track lengths for VBR tracks if the
track doesn't contain a Xing header so the displayed track length can be wildly
wrong. This just checks the actual time a track played against what we have
in the DB and updates the DB if it is wrong.
  • Loading branch information...
1 parent b9f2436 commit 73ade815672ab1c2892f3008688284295483375e Paul Harrison committed Sep 20, 2011
Showing with 21 additions and 4 deletions.
  1. +21 −4 mythplugins/mythmusic/mythmusic/musicplayer.cpp
View
25 mythplugins/mythmusic/mythmusic/musicplayer.cpp
@@ -630,10 +630,6 @@ void MusicPlayer::customEvent(QEvent *event)
.arg(*aoe->errorMessage()));
stop(true);
}
- else if (event->type() == DecoderEvent::Finished)
- {
- nextAuto();
- }
else if (event->type() == DecoderEvent::Error)
{
stop(true);
@@ -668,6 +664,27 @@ void MusicPlayer::customEvent(QEvent *event)
}
}
}
+ else if (event->type() == DecoderEvent::Finished)
+ {
+ if (m_currentMetadata && m_currentTime != m_currentMetadata->Length() / 1000)
+ {
+ LOG(VB_GENERAL, LOG_NOTICE, QString("MusicPlayer: Updating track length was %1s, should be %2s")
+ .arg(m_currentMetadata->Length() / 1000).arg(m_currentTime));
+
+ m_currentMetadata->setLength(m_currentTime * 1000);
+ m_currentMetadata->dumpToDatabase();
+
+ // this will update any track lengths displayed on screen
+ gPlayer->sendMetadataChangedEvent(m_currentMetadata->ID());
+
+ // this will force the playlist stats to update
+ MusicPlayerEvent me(MusicPlayerEvent::TrackChangeEvent, m_currentTrack);
+ dispatch(me);
+ }
+
+ if (m_isAutoplay)
+ nextAuto();
+ }
QObject::customEvent(event);
}

0 comments on commit 73ade81

Please sign in to comment.