Add untested play/pause event code and change web interface to know which happened.
This commit is contained in:
@@ -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)
|
||||
{
|
||||
|
||||
@@ -57,7 +57,7 @@ void WebInterface::loginCompleted()
|
||||
//TODO: request current player state.
|
||||
}
|
||||
|
||||
void WebInterface::playPauseActionFromServer(User userPausing)
|
||||
void WebInterface::playPauseActionFromServer(User userPausing, bool pause)
|
||||
{
|
||||
priv_int->playerUI->tempText->setText(priv_int->playerUI->tempText->text()+"play");
|
||||
triggerUpdate();
|
||||
|
||||
@@ -31,7 +31,7 @@ public:
|
||||
WebInterface(const Wt::WEnvironment& env);
|
||||
~WebInterface();
|
||||
void loginCompleted();
|
||||
void playPauseActionFromServer(User userPausing);
|
||||
void playPauseActionFromServer(User userPausing, bool pause);
|
||||
void songChangedFromServer(AudioTrack nextTrack);
|
||||
void voteTracksUpdatedFromServer(std::list<AudioTrack> voteableTracks);
|
||||
void skipVotedFromServer(User userRequestingToSkipCurrentTrack);
|
||||
|
||||
Reference in New Issue
Block a user