From ade17ed6889f2577fe12cd62f64e5b5816c82c62 Mon Sep 17 00:00:00 2001 From: Andrzej Rybczak Date: Sun, 16 Nov 2008 21:05:18 +0100 Subject: [PATCH] consider crossfade if there is only one song in playlist looped --- src/callback.cpp | 5 +++-- src/mpdpp.h | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/callback.cpp b/src/callback.cpp index 2a02000..198acc2 100644 --- a/src/callback.cpp +++ b/src/callback.cpp @@ -56,7 +56,8 @@ void ScrobbyStatusChanged(MPD::Connection *Mpd, MPD::StatusChanges changed, void } if (changed.ElapsedTime) { - if (!Mpd->GetElapsedTime()) + static int crossfade; + if (Mpd->GetPlaylistLength() == 1 && Mpd->GetElapsedTime() == ((crossfade = Mpd->GetCrossfade()) ? crossfade : 0 )) changed.SongID = 1; s.Playback()++; } @@ -68,7 +69,7 @@ void ScrobbyStatusChanged(MPD::Connection *Mpd, MPD::StatusChanges changed, void if (old_state == MPD::psPlay && current_state == MPD::psStop) old_state = MPD::psUnknown; - if (Mpd->GetElapsedTime() < 5) + if (Mpd->GetElapsedTime() < Mpd->GetCrossfade()+5) s.SetStartTime(); if (current_state == MPD::psPlay || current_state == MPD::psPause) diff --git a/src/mpdpp.h b/src/mpdpp.h index 683356a..933f801 100644 --- a/src/mpdpp.h +++ b/src/mpdpp.h @@ -62,6 +62,8 @@ namespace MPD { State GetState() const { return isConnected && itsCurrentStatus ? (State)itsCurrentStatus->state : psUnknown; } int GetElapsedTime() const { return isConnected && itsCurrentStatus ? itsCurrentStatus->elapsedTime : -1; } + int GetCrossfade() const { return isConnected && itsCurrentStatus ? itsCurrentStatus->crossfade : -1; } + int GetPlaylistLength() const { return isConnected && itsCurrentStatus ? itsCurrentStatus->playlistLength : -1; } const std::string & GetErrorMessage() const { return itsErrorMessage; } int GetErrorCode() const { return itsErrorCode; } -- 2.11.4.GIT