Add untested play/pause event code and change web interface to know which happened.

This commit is contained in:
Kevin Whitaker
2017-02-08 23:22:34 -05:00
parent 35279008ee
commit 41fa567f82
3 changed files with 44 additions and 4 deletions

View File

@@ -389,11 +389,51 @@ void GroovePlayerMgr::grooveEventLoop()
}
else if(event.eventType == PLAYING_PAUSED)
{
//TODO
//Add action to DB
Wt::Dbo::Transaction pauseTransaction(sqlSession);
UserAction* action = new UserAction();
action->action = UserAction::UAction::PlayPause;
action->user = Wt::Dbo::ptr<User>(&event.userInvolved);
action->trackInvolved = Wt::Dbo::ptr<AudioTrack>(&event.tracksInvolved.front());
action->datetime = Wt::WDateTime::currentDateTime();
sqlSession.add(action);
pauseTransaction.commit();
groove_playlist_pause(currentPlaylist);
//Update vote display on all clients.
Wt::WServer::instance()->postAll([event]() {
Wt::WApplication* app = Wt::WApplication::instance();
if(app != nullptr)
{
static_cast<WebInterface*>(app)->playPauseActionFromServer(event.userInvolved, true);
}
}
);
}
else if(event.eventType == PLAYING_RESUMED)
{
//TODO
//Add action to DB
Wt::Dbo::Transaction playTransaction(sqlSession);
UserAction* action = new UserAction();
action->action = UserAction::UAction::PlayPause;
action->user = Wt::Dbo::ptr<User>(&event.userInvolved);
action->trackInvolved = Wt::Dbo::ptr<AudioTrack>(&event.tracksInvolved.front());
action->datetime = Wt::WDateTime::currentDateTime();
sqlSession.add(action);
playTransaction.commit();
groove_playlist_play(currentPlaylist);
//Update vote display on all clients.
Wt::WServer::instance()->postAll([event]() {
Wt::WApplication* app = Wt::WApplication::instance();
if(app != nullptr)
{
static_cast<WebInterface*>(app)->playPauseActionFromServer(event.userInvolved, false);
}
}
);
}
else if(event.eventType == SKIP_REQUESTED)
{