Start implementing web UI. Add track detail container. Comment out some old test code and DB code while more gets hooked up. Play/pause button is mostly implemented.
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -390,15 +390,15 @@ 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<User>(&event.userInvolved);
|
||||
action->trackInvolved = Wt::Dbo::ptr<AudioTrack>(&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<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);
|
||||
|
||||
@@ -414,15 +414,15 @@ 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<User>(&event.userInvolved);
|
||||
action->trackInvolved = Wt::Dbo::ptr<AudioTrack>(&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<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);
|
||||
|
||||
|
||||
@@ -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<AudioTrack> voteableTracks)
|
||||
{
|
||||
priv_int->playerUI->tempText->setText(priv_int->playerUI->tempText->text()+"votechanged");
|
||||
//priv_int->playerUI->tempText->setText(priv_int->playerUI->tempText->text()+"votechanged");
|
||||
triggerUpdate();
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -19,10 +19,57 @@
|
||||
|
||||
#include "PlayerInterface.h"
|
||||
#include <Wt/WText>
|
||||
#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");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,15 +21,44 @@
|
||||
#define PLAYERINTERFACE_H
|
||||
|
||||
#include <Wt/WContainerWidget>
|
||||
#include <Wt/WHBoxLayout>
|
||||
#include <Wt/WVBoxLayout>
|
||||
#include "../WebInterface.h"
|
||||
#include <Wt/WPushButton>
|
||||
#include <Wt/WText>
|
||||
#include <Wt/WProgressBar>
|
||||
#include <Wt/WTimer>
|
||||
#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
|
||||
|
||||
20
src/ui/TrackDetails.cpp
Normal file
20
src/ui/TrackDetails.cpp
Normal file
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright (C) 2017 Kevin Whitaker <eyecreate@gmail.com>
|
||||
*
|
||||
* 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"
|
||||
29
src/ui/TrackDetails.h
Normal file
29
src/ui/TrackDetails.h
Normal file
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright (C) 2017 Kevin Whitaker <eyecreate@gmail.com>
|
||||
*
|
||||
* 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 <Wt/WContainerWidget>
|
||||
|
||||
class TrackDetails : Wt::WContainerWidget
|
||||
{
|
||||
};
|
||||
|
||||
#endif // TRACKDETAILS_H
|
||||
Reference in New Issue
Block a user