get rid of Playlist::PlayNewlyAddedSongs / correct adding songs in Media Library

This commit is contained in:
Andrzej Rybczak
2013-05-17 16:55:50 +02:00
parent 2f9ab8f267
commit 7deeecee20
10 changed files with 85 additions and 70 deletions

View File

@@ -485,8 +485,38 @@ template <typename BufferT> void ShowTag(BufferT &buf, const std::string &tag)
buf << tag;
}
template <typename SongIterator>
void addSongsToPlaylist(SongIterator first, SongIterator last, bool play, int position)
{
if (last-first >= 1)
{
int id = Mpd.AddSong(*first, position);
if (id > 0)
{
Mpd.StartCommandsList();
if (position == -1)
{
++first;
for(; first != last; ++first)
if (Mpd.AddSong(*first) < 0)
break;
}
else
{
++position;
--last;
for (; first != last; --last)
if (Mpd.AddSong(*last, position) < 0)
break;
}
Mpd.CommitCommandsList();
if (play)
Mpd.PlayID(id);
}
}
}
bool addSongToPlaylist(const MPD::Song &s, bool play, int position = -1);
void addSongsToPlaylist(const MPD::SongList &list, bool play, int position = -1);
std::string Timestamp(time_t t);