diff --git a/CMakeLists.txt b/CMakeLists.txt index d170192eec1fbafcbd8b9063c857d85e26dcba1e..b74af1dcfe80a7a23d4bed39f06caa461a1edb7a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,7 +9,7 @@ find_package(Wt REQUIRED) find_package(Groove REQUIRED) find_package(TagLib REQUIRED) -add_executable(arbitrateor src/main.cpp src/WebInterface.cpp src/GroovePlayer.cpp src/ui/LoginInterface.cpp src/ui/PlayerInterface.cpp) +add_executable(arbitrateor src/main.cpp src/WebInterface.cpp src/GroovePlayer.cpp src/ui/LoginInterface.cpp src/ui/PlayerInterface.cpp src/ui/TrackDetails.cpp) target_link_libraries(arbitrateor ${Wt_LIBRARIES} ${GROOVE_LIBRARY} ${GROOVE_FINGERPRINT_LIBRARY} ${GROOVE_PLAYER_LIBRARY} ${TAGLIB_LIBRARY} pthread stdc++fs) #TODO get threading links based on platform. Remove gcc experimental fs when official c++17 exists. install(TARGETS arbitrateor RUNTIME DESTINATION bin) diff --git a/src/GroovePlayer.cpp b/src/GroovePlayer.cpp index c14fb5dff794b2b1a4691b6c370003db36f7a4a4..5ca4fd14a74d12ef6aeefceef80e3900ec1aaed6 100644 --- a/src/GroovePlayer.cpp +++ b/src/GroovePlayer.cpp @@ -390,16 +390,16 @@ void GroovePlayerMgr::grooveEventLoop() } else if(event.eventType == PLAYING_PAUSED) { - //Add action to DB - Wt::Dbo::Transaction pauseTransaction(sqlSession); - UserAction* action = new UserAction(); - action->action = UserAction::UAction::PlayPause; - action->user = Wt::Dbo::ptr(&event.userInvolved); - action->trackInvolved = Wt::Dbo::ptr(&event.tracksInvolved.front()); - action->datetime = Wt::WDateTime::currentDateTime(); - sqlSession.add(action); - pauseTransaction.commit(); - + //Add action to DB TODO +// Wt::Dbo::Transaction pauseTransaction(sqlSession); +// UserAction* action = new UserAction(); +// action->action = UserAction::UAction::PlayPause; +// action->user = Wt::Dbo::ptr(&event.userInvolved); +// action->trackInvolved = Wt::Dbo::ptr(&event.tracksInvolved.front()); +// action->datetime = Wt::WDateTime::currentDateTime(); +// sqlSession.add(action); +// pauseTransaction.commit(); + groove_playlist_pause(currentPlaylist); //Update vote display on all clients. @@ -414,16 +414,16 @@ void GroovePlayerMgr::grooveEventLoop() } else if(event.eventType == PLAYING_RESUMED) { - //Add action to DB - Wt::Dbo::Transaction playTransaction(sqlSession); - UserAction* action = new UserAction(); - action->action = UserAction::UAction::PlayPause; - action->user = Wt::Dbo::ptr(&event.userInvolved); - action->trackInvolved = Wt::Dbo::ptr(&event.tracksInvolved.front()); - action->datetime = Wt::WDateTime::currentDateTime(); - sqlSession.add(action); - playTransaction.commit(); - + //Add action to DB TODO +// Wt::Dbo::Transaction playTransaction(sqlSession); +// UserAction* action = new UserAction(); +// action->action = UserAction::UAction::PlayPause; +// action->user = Wt::Dbo::ptr(&event.userInvolved); +// action->trackInvolved = Wt::Dbo::ptr(&event.tracksInvolved.front()); +// action->datetime = Wt::WDateTime::currentDateTime(); +// sqlSession.add(action); +// playTransaction.commit(); + groove_playlist_play(currentPlaylist); //Update vote display on all clients. diff --git a/src/WebInterface.cpp b/src/WebInterface.cpp index 67a83db02cce6089bbbaef6505e439ccd10a6d7d..6a2ec9e591799a68aaa04ec038593b6e9eae4cf4 100644 --- a/src/WebInterface.cpp +++ b/src/WebInterface.cpp @@ -59,42 +59,43 @@ void WebInterface::loginCompleted() void WebInterface::playPauseActionFromServer(User userPausing, bool pause) { - priv_int->playerUI->tempText->setText(priv_int->playerUI->tempText->text()+"play"); + priv_int->playerUI->isPaused = pause; + priv_int->playerUI->playpauseUpdated(); triggerUpdate(); } void WebInterface::songChangedFromServer(AudioTrack nextTrack) { - priv_int->playerUI->tempText->setText(priv_int->playerUI->tempText->text()+"change"); + //priv_int->playerUI->tempText->setText(priv_int->playerUI->tempText->text()+"change"); triggerUpdate(); } void WebInterface::skipVotedFromServer(User userRequestingToSkipCurrentTrack) { - priv_int->playerUI->tempText->setText(priv_int->playerUI->tempText->text()+"skip"); + //priv_int->playerUI->tempText->setText(priv_int->playerUI->tempText->text()+"skip"); triggerUpdate(); } void WebInterface::skipVoteUpdateFromServer(User userVoting, bool forSkip) { - priv_int->playerUI->tempText->setText(priv_int->playerUI->tempText->text()+"vote"); + //priv_int->playerUI->tempText->setText(priv_int->playerUI->tempText->text()+"vote"); triggerUpdate(); } void WebInterface::voteNextSongFromServer(User userVoting, AudioTrack trackVoted) { - priv_int->playerUI->tempText->setText(priv_int->playerUI->tempText->text()+"nextvote"); + //priv_int->playerUI->tempText->setText(priv_int->playerUI->tempText->text()+"nextvote"); triggerUpdate(); } void WebInterface::voteNextPollClosedFromServer() { - priv_int->playerUI->tempText->setText(priv_int->playerUI->tempText->text()+"voteclosed"); + //priv_int->playerUI->tempText->setText(priv_int->playerUI->tempText->text()+"voteclosed"); triggerUpdate(); } void WebInterface::voteTracksUpdatedFromServer(std::list voteableTracks) { - priv_int->playerUI->tempText->setText(priv_int->playerUI->tempText->text()+"votechanged"); + //priv_int->playerUI->tempText->setText(priv_int->playerUI->tempText->text()+"votechanged"); triggerUpdate(); } diff --git a/src/WebInterface.h b/src/WebInterface.h index 2d908536cd7cdd7e1fd8d0f9b8dc84052a33caea..647335eaf25cda95647830a6e9a0135b5ec7fcfb 100644 --- a/src/WebInterface.h +++ b/src/WebInterface.h @@ -38,6 +38,7 @@ public: void skipVoteUpdateFromServer(User userVoting, bool forSkip); void voteNextSongFromServer(User userVoting, AudioTrack trackVoted); void voteNextPollClosedFromServer(); + User currentUser; private: struct internal; internal* priv_int = 0; diff --git a/src/ui/PlayerInterface.cpp b/src/ui/PlayerInterface.cpp index a12c73fde561716852363859425c2738b35a84ec..6d1015a7d359ae60ed5db613dca0c8f30530106c 100644 --- a/src/ui/PlayerInterface.cpp +++ b/src/ui/PlayerInterface.cpp @@ -19,10 +19,57 @@ #include "PlayerInterface.h" #include +#include "../GroovePlayer.h" PlayerInterface::PlayerInterface(WebInterface* app) { this->app = app; - tempText = new Wt::WText("You did it."); - addChild(tempText); + interfaceLayout = new Wt::WVBoxLayout(); + this->setLayout(interfaceLayout); + playControlContainer = new Wt::WContainerWidget(); + voteControlContainer = new Wt::WContainerWidget(); + playControlLayout = new Wt::WHBoxLayout(); + voteControlLayout = new Wt::WVBoxLayout(); + playControlContainer->setLayout(playControlLayout); + voteControlContainer->setLayout(voteControlLayout); + + currentTrackProgress = new Wt::WProgressBar(); + currentTrackProgress->setFormat(""); + trackProgress = new Wt::WTimer(); + trackProgress->setInterval(1000); + //TODO:track details + playpause = new Wt::WPushButton(); + playpause->setText(groove_playlist_playing(GroovePlayerMgr::getInstance()->currentPlaylist)==1?"Pause":"Resume"); + isPaused = groove_playlist_playing(GroovePlayerMgr::getInstance()->currentPlaylist)==0; + playpause->clicked().connect(this, &PlayerInterface::playpauseClicked); + + interfaceLayout->addWidget(playControlContainer); + interfaceLayout->addWidget(currentTrackProgress); + interfaceLayout->addWidget(voteControlContainer); + //TODO:add track details + playControlLayout->addWidget(playpause); +} + +void PlayerInterface::playpauseClicked() +{ + if(!isPaused) + { + GroovePlayerMgr::getInstance()->lastInternalEvents.push_back(GroovePlayerMgr::PlayerEvent() = {GroovePlayerMgr::PlayerEventType::PLAYING_PAUSED, app->currentUser}); + } + else + { + GroovePlayerMgr::getInstance()->lastInternalEvents.push_back(GroovePlayerMgr::PlayerEvent() = {GroovePlayerMgr::PlayerEventType::PLAYING_RESUMED, app->currentUser}); + } +} + +void PlayerInterface::playpauseUpdated() +{ + if(isPaused) + { + playpause->setText("Resume"); + } + else + { + playpause->setText("Pause"); + } } diff --git a/src/ui/PlayerInterface.h b/src/ui/PlayerInterface.h index e8df3f47349a0c2c6957f1bc9610c6fd1cac6be2..1c5731584a777bb237f9ca856184b86631f768d6 100644 --- a/src/ui/PlayerInterface.h +++ b/src/ui/PlayerInterface.h @@ -21,15 +21,44 @@ #define PLAYERINTERFACE_H #include +#include +#include #include "../WebInterface.h" +#include #include +#include +#include +#include "TrackDetails.h" class PlayerInterface : public Wt::WContainerWidget { public: PlayerInterface(WebInterface* app); WebInterface* app; - Wt::WText* tempText; + + Wt::WVBoxLayout* interfaceLayout; + Wt::WContainerWidget* playControlContainer; + Wt::WHBoxLayout* playControlLayout; + Wt::WVBoxLayout* voteControlLayout; + Wt::WContainerWidget* voteControlContainer; + + //Play controls + TrackDetails* currentTrackDetails; + Wt::WProgressBar* currentTrackProgress; + Wt::WTimer* trackProgress; + Wt::WHBoxLayout* currentTrackLayout; + Wt::WContainerWidget* currentTrackContainer; + Wt::WPushButton* playpause; + + bool isPaused = false; + //TODO:put in controls for requesting/admin skip and adding users as admin. + + //Vote controls + //TODO:put in vote controls for seeing tracks to vote on and vote buttons. + //TODO:put in controls for requesting songs. + + void playpauseClicked(); + void playpauseUpdated(); }; #endif // PLAYERINTERFACE_H diff --git a/src/ui/TrackDetails.cpp b/src/ui/TrackDetails.cpp new file mode 100644 index 0000000000000000000000000000000000000000..9656257fe154e178348bbf42d706f78ca4cfd9fe --- /dev/null +++ b/src/ui/TrackDetails.cpp @@ -0,0 +1,20 @@ +/* + * Copyright (C) 2017 Kevin Whitaker + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + */ + +#include "TrackDetails.h" diff --git a/src/ui/TrackDetails.h b/src/ui/TrackDetails.h new file mode 100644 index 0000000000000000000000000000000000000000..b01f73eb71b986a30ffedb6e372d52e3e727a65c --- /dev/null +++ b/src/ui/TrackDetails.h @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2017 Kevin Whitaker + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + */ + +#ifndef TRACKDETAILS_H +#define TRACKDETAILS_H + +#include + +class TrackDetails : Wt::WContainerWidget +{ +}; + +#endif // TRACKDETAILS_H