add boost in because wt seems to now complain about it. Remove first song change message as it's unlikely anyone will encounter it with other events firing soon after. Start cleaning up some container/layout mess. Implement trackdetails and show this on the play controls.
This commit is contained in:
@@ -10,6 +10,6 @@ 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 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.
|
||||
target_link_libraries(arbitrateor ${Wt_LIBRARIES} ${GROOVE_LIBRARY} ${GROOVE_FINGERPRINT_LIBRARY} ${GROOVE_PLAYER_LIBRARY} ${TAGLIB_LIBRARY} pthread boost_system stdc++fs) #TODO get threading links based on platform. Remove gcc experimental fs when official c++17 exists.
|
||||
|
||||
install(TARGETS arbitrateor RUNTIME DESTINATION bin)
|
||||
|
||||
@@ -221,14 +221,6 @@ void GroovePlayerMgr::grooveEventLoop()
|
||||
//Now boostrap player with initial data
|
||||
groove_player_attach(player, playlist);
|
||||
groove_playlist_play(playlist);
|
||||
Wt::WServer::instance()->postAll([&]() {
|
||||
Wt::WApplication* app = Wt::WApplication::instance();
|
||||
if(app != nullptr)
|
||||
{
|
||||
static_cast<WebInterface*>(app)->songChangedFromServer(currentTrack);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
//Now start loop
|
||||
while(getInstance()->continueEventLoop)
|
||||
@@ -243,6 +235,7 @@ void GroovePlayerMgr::grooveEventLoop()
|
||||
{
|
||||
currentSkipRequester.clear();
|
||||
currentTrack = getCurrentTrackDB(&sqlSession);
|
||||
getPictureFromTrack(¤tTrack);
|
||||
//Pick new batch of tracks to vote on and inform UI of update.
|
||||
currentVoteBatch = getNextVoteBatch(&sqlSession);
|
||||
currentVoteStatus = std::list<std::pair<AudioTrack, int>>();
|
||||
|
||||
@@ -21,35 +21,33 @@
|
||||
#include <Wt/WText>
|
||||
#include "../GroovePlayer.h"
|
||||
#include <grooveplayer/player.h>
|
||||
#include <Wt/WLength>
|
||||
|
||||
PlayerInterface::PlayerInterface(WebInterface* app)
|
||||
{
|
||||
this->app = app;
|
||||
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);
|
||||
trackProgress->timeout().connect(this,&PlayerInterface::updateProgressFromTimer);
|
||||
//TODO:track details
|
||||
currentTrackDetails = new TrackDetails();
|
||||
playpause = new Wt::WPushButton();
|
||||
playpause->setText(groove_playlist_playing(GroovePlayerMgr::getInstance()->currentPlaylist)==1?"Pause":"Resume");
|
||||
playpause->setMaximumSize(Wt::WLength(60,Wt::WLength::Point),Wt::WLength(30,Wt::WLength::Point));
|
||||
isPaused = groove_playlist_playing(GroovePlayerMgr::getInstance()->currentPlaylist)==0;
|
||||
playpause->clicked().connect(this, &PlayerInterface::playpauseClicked);
|
||||
|
||||
interfaceLayout->addWidget(playControlContainer);
|
||||
interfaceLayout->addLayout(playControlLayout);
|
||||
interfaceLayout->addWidget(currentTrackProgress);
|
||||
interfaceLayout->addWidget(voteControlContainer);
|
||||
//TODO:add track details
|
||||
playControlLayout->addWidget(playpause);
|
||||
interfaceLayout->addLayout(voteControlLayout);
|
||||
playControlLayout->addWidget(playpause,0,Wt::AlignmentFlag::AlignCenter | Wt::AlignmentFlag::AlignMiddle);
|
||||
playControlLayout->addWidget(currentTrackDetails);
|
||||
}
|
||||
|
||||
void PlayerInterface::playpauseClicked()
|
||||
@@ -93,7 +91,6 @@ void PlayerInterface::updateProgressFromTimer()
|
||||
|
||||
void PlayerInterface::updateDetailsFromServer(AudioTrack track)
|
||||
{
|
||||
//TODO: request current player state.
|
||||
//Find current song playing and set progress state.
|
||||
double secondsIn;
|
||||
groove_player_position(GroovePlayerMgr::getInstance()->currentPlayer,nullptr, &secondsIn);
|
||||
@@ -105,4 +102,5 @@ void PlayerInterface::updateDetailsFromServer(AudioTrack track)
|
||||
trackProgress->start();
|
||||
}
|
||||
playpauseUpdated();
|
||||
currentTrackDetails->updateWithTrackDetails(track);
|
||||
}
|
||||
|
||||
@@ -37,10 +37,8 @@ public:
|
||||
WebInterface* app;
|
||||
|
||||
Wt::WVBoxLayout* interfaceLayout;
|
||||
Wt::WContainerWidget* playControlContainer;
|
||||
Wt::WHBoxLayout* playControlLayout;
|
||||
Wt::WVBoxLayout* voteControlLayout;
|
||||
Wt::WContainerWidget* voteControlContainer;
|
||||
|
||||
//Play controls
|
||||
TrackDetails* currentTrackDetails;
|
||||
|
||||
@@ -18,3 +18,37 @@
|
||||
*/
|
||||
|
||||
#include "TrackDetails.h"
|
||||
#include <Wt/WLength>
|
||||
|
||||
TrackDetails::TrackDetails()
|
||||
{
|
||||
mainLayout = new Wt::WHBoxLayout();
|
||||
this->setLayout(mainLayout);
|
||||
metaContainer = new Wt::WContainerWidget();
|
||||
metaLayout = new Wt::WVBoxLayout();
|
||||
metaContainer->setLayout(metaLayout);
|
||||
coverData = new Wt::WMemoryResource();
|
||||
albumCover = new Wt::WImage();
|
||||
albumCover->setMinimumSize(Wt::WLength(100,Wt::WLength::Pixel),Wt::WLength(100,Wt::WLength::Pixel));
|
||||
albumCover->setMaximumSize(Wt::WLength(200,Wt::WLength::Pixel),Wt::WLength(200,Wt::WLength::Pixel));
|
||||
mainLayout->addWidget(albumCover);
|
||||
mainLayout->addWidget(metaContainer);
|
||||
trackTitle = new Wt::WText();
|
||||
trackArtist = new Wt::WText();
|
||||
trackAlbum = new Wt::WText();
|
||||
metaLayout->addWidget(trackTitle);
|
||||
metaLayout->addWidget(trackArtist);
|
||||
metaLayout->addWidget(trackAlbum);
|
||||
}
|
||||
|
||||
void TrackDetails::updateWithTrackDetails(AudioTrack track)
|
||||
{
|
||||
trackTitle->setText(track.trackName);
|
||||
trackArtist->setText(track.trackArtistName);
|
||||
trackAlbum->setText(track.trackAlbumName);
|
||||
|
||||
//Set image to data from track obj.
|
||||
coverData = new Wt::WMemoryResource(track.coverMimeType);
|
||||
coverData->setData((unsigned char*)track.coverArt.data(),std::stoi(std::to_string(track.coverArt.size())));
|
||||
albumCover->setResource(coverData);
|
||||
}
|
||||
|
||||
@@ -21,9 +21,28 @@
|
||||
#define TRACKDETAILS_H
|
||||
|
||||
#include <Wt/WContainerWidget>
|
||||
#include <Wt/WHBoxLayout>
|
||||
#include <Wt/WVBoxLayout>
|
||||
#include <Wt/WText>
|
||||
#include <Wt/WImage>
|
||||
#include <Wt/WMemoryResource>
|
||||
#include "../db/AudioTrack.h"
|
||||
|
||||
class TrackDetails : Wt::WContainerWidget
|
||||
class TrackDetails : public Wt::WContainerWidget
|
||||
{
|
||||
public:
|
||||
TrackDetails();
|
||||
Wt::WHBoxLayout* mainLayout;
|
||||
Wt::WContainerWidget* metaContainer;
|
||||
Wt::WVBoxLayout* metaLayout;
|
||||
|
||||
Wt::WImage* albumCover;
|
||||
Wt::WMemoryResource* coverData;
|
||||
Wt::WText* trackTitle;
|
||||
Wt::WText* trackArtist;
|
||||
Wt::WText* trackAlbum;
|
||||
|
||||
void updateWithTrackDetails(AudioTrack track);
|
||||
};
|
||||
|
||||
#endif // TRACKDETAILS_H
|
||||
|
||||
Reference in New Issue
Block a user