WIP. Basic Prev/Next support in play queue

This commit is contained in:
emeric
2014-11-05 12:57:10 +01:00
parent d0e472028d
commit 81d758b420
5 changed files with 46 additions and 30 deletions
+21 -3
View File
@@ -25,7 +25,7 @@ namespace UserInterface {
PlayQueue::PlayQueue(Database::Handler& db, Wt::WContainerWidget* parent)
: Wt::WTableView(parent),
_db(db),
_playingTrackId(0)
_playedId(-1)
{
_model = new Wt::WStandardItemModel(0, 4, this);
@@ -97,13 +97,31 @@ void
PlayQueue::clear(void)
{
_model->removeRows(0, _model->rowCount());
// Reset play id
_playedId = -1;
}
void
PlayQueue::handlePlaybackComplete(void)
{
// Play the next track
readTrack(_playingTrackId + 1);
if (_playedId != -1)
{
readTrack(_playedId + 1);
}
}
void
PlayQueue::playNext(void)
{
readTrack( _playedId != -1 ? _playedId + 1 : 0);
}
void
PlayQueue::playPrevious(void)
{
readTrack( _playedId >= 1 ? _playedId - 1 : 0);
}
void
@@ -118,7 +136,7 @@ PlayQueue::readTrack(int rowId)
Database::Track::pointer track = Database::Track::getById(_db.getSession(), trackId);
if (track)
{
_playingTrackId = rowId;
_playedId = rowId;
_sigTrackPlay.emit(track->getPath());
break;
}