'repeat one song' mode added + memleak fix and some code clean-ups
This commit is contained in:
@@ -75,6 +75,8 @@ extern bool block_library_update;
|
||||
|
||||
extern bool redraw_me;
|
||||
|
||||
bool repeat_one_allowed = 0;
|
||||
|
||||
long long playlist_old_id = -1;
|
||||
|
||||
int old_playing;
|
||||
@@ -325,11 +327,17 @@ void NcmpcppStatusChanged(MPDConnection *Mpd, MPDStatusChanges changed, void *da
|
||||
{
|
||||
if (!mPlaylist->Empty())
|
||||
{
|
||||
if (Config.repeat_one_mode && repeat_one_allowed && old_playing+1 == now_playing)
|
||||
{
|
||||
std::swap<int>(now_playing,old_playing);
|
||||
Mpd->Play(now_playing);
|
||||
}
|
||||
if (old_playing >= 0)
|
||||
mPlaylist->BoldOption(old_playing+1, 0);
|
||||
mPlaylist->BoldOption(now_playing+1, 1);
|
||||
if (Config.autocenter_mode)
|
||||
mPlaylist->Highlight(now_playing+1);
|
||||
repeat_one_allowed = 0;
|
||||
}
|
||||
if (!Mpd->GetElapsedTime())
|
||||
mvwhline(wFooter->RawWin(), 0, 0, 0, wFooter->GetWidth());
|
||||
@@ -348,6 +356,10 @@ void NcmpcppStatusChanged(MPDConnection *Mpd, MPDStatusChanges changed, void *da
|
||||
|
||||
int elapsed = Mpd->GetElapsedTime();
|
||||
|
||||
// 'repeat one' mode check - be sure that we deal with item with known length
|
||||
if (Mpd->GetCurrentSong().GetTotalLength() && elapsed == Mpd->GetCurrentSong().GetTotalLength())
|
||||
repeat_one_allowed = 1;
|
||||
|
||||
if (!block_statusbar_update && Config.statusbar_visibility)
|
||||
{
|
||||
string tracklength;
|
||||
|
||||
Reference in New Issue
Block a user