Merge branch 'new-layout' into develop
This commit is contained in:
@@ -51,6 +51,7 @@ lms_SOURCES = \
|
|||||||
$(srcdir)/ui/common/DirectoryValidator.cpp \
|
$(srcdir)/ui/common/DirectoryValidator.cpp \
|
||||||
$(srcdir)/ui/common/SessionData.cpp \
|
$(srcdir)/ui/common/SessionData.cpp \
|
||||||
$(srcdir)/ui/resource/AvConvTranscodeStreamResource.cpp \
|
$(srcdir)/ui/resource/AvConvTranscodeStreamResource.cpp \
|
||||||
|
$(srcdir)/ui/resource/CoverResource.cpp \
|
||||||
$(srcdir)/ui/video/VideoWidget.cpp \
|
$(srcdir)/ui/video/VideoWidget.cpp \
|
||||||
$(srcdir)/ui/video/VideoDatabaseWidget.cpp \
|
$(srcdir)/ui/video/VideoDatabaseWidget.cpp \
|
||||||
$(srcdir)/ui/video/VideoMediaPlayerWidget.cpp \
|
$(srcdir)/ui/video/VideoMediaPlayerWidget.cpp \
|
||||||
|
|||||||
@@ -114,6 +114,19 @@ InputFormatContext::getMetadata(void)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::size_t
|
||||||
|
InputFormatContext::getNbPictures(void) const
|
||||||
|
{
|
||||||
|
std::size_t res = 0;
|
||||||
|
|
||||||
|
for (std::size_t i = 0; i < native()->nb_streams; ++i)
|
||||||
|
{
|
||||||
|
if (native()->streams[i]->disposition & AV_DISPOSITION_ATTACHED_PIC)
|
||||||
|
++res;
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
InputFormatContext::getPictures(std::vector< std::vector<unsigned char> >& pictures) const
|
InputFormatContext::getPictures(std::vector< std::vector<unsigned char> >& pictures) const
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ class InputFormatContext : public FormatContext
|
|||||||
|
|
||||||
|
|
||||||
// Get attached pictures
|
// Get attached pictures
|
||||||
|
std::size_t getNbPictures(void) const;
|
||||||
void getPictures(std::vector< std::vector<unsigned char> >& pictures) const;
|
void getPictures(std::vector< std::vector<unsigned char> >& pictures) const;
|
||||||
|
|
||||||
// Get the streams
|
// Get the streams
|
||||||
|
|||||||
@@ -52,6 +52,25 @@ Grabber::getFromInputFormatContext(const Av::InputFormatContext& input)
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<CoverArt>
|
||||||
|
Grabber::getFromTrack(const boost::filesystem::path& p)
|
||||||
|
{
|
||||||
|
std::vector<CoverArt> res;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Av::InputFormatContext input(p);
|
||||||
|
|
||||||
|
return getFromInputFormatContext(input);
|
||||||
|
|
||||||
|
}
|
||||||
|
catch(std::exception& e)
|
||||||
|
{
|
||||||
|
LMS_LOG(MOD_COVER, SEV_ERROR) << "Cannot get pictures: " << e.what();
|
||||||
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ class Grabber
|
|||||||
|
|
||||||
static std::vector<CoverArt> getFromInputFormatContext(const Av::InputFormatContext& input);
|
static std::vector<CoverArt> getFromInputFormatContext(const Av::InputFormatContext& input);
|
||||||
static std::vector<CoverArt> getFromTrack(Database::Track::pointer track);
|
static std::vector<CoverArt> getFromTrack(Database::Track::pointer track);
|
||||||
|
static std::vector<CoverArt> getFromTrack(const boost::filesystem::path& path);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace CoverArt
|
} // namespace CoverArt
|
||||||
|
|||||||
@@ -402,6 +402,11 @@ Updater::processAudioFile( const boost::filesystem::path& file, Stats& stats)
|
|||||||
track.modify()->setDate( boost::any_cast<boost::posix_time::ptime>(items[MetaData::Type::OriginalDate]) );
|
track.modify()->setDate( boost::any_cast<boost::posix_time::ptime>(items[MetaData::Type::OriginalDate]) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (items.find(MetaData::Type::HasCover) != items.end())
|
||||||
|
{
|
||||||
|
track.modify()->setHasCover( boost::any_cast<bool>(items[MetaData::Type::HasCover]));
|
||||||
|
}
|
||||||
|
|
||||||
transaction.commit();
|
transaction.commit();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -117,6 +117,7 @@ class Track
|
|||||||
void setOriginalDate(const boost::posix_time::ptime& date) { _originalDate = date; }
|
void setOriginalDate(const boost::posix_time::ptime& date) { _originalDate = date; }
|
||||||
void setGenres(const std::string& genreList) { _genreList = genreList; }
|
void setGenres(const std::string& genreList) { _genreList = genreList; }
|
||||||
void setGenres(std::vector<Genre::pointer> genres);
|
void setGenres(std::vector<Genre::pointer> genres);
|
||||||
|
void setHasCover(bool hasCover) { _hasCover = hasCover; }
|
||||||
|
|
||||||
int getTrackNumber(void) const { return _trackNumber; }
|
int getTrackNumber(void) const { return _trackNumber; }
|
||||||
int getDiscNumber(void) const { return _discNumber; }
|
int getDiscNumber(void) const { return _discNumber; }
|
||||||
@@ -132,6 +133,7 @@ class Track
|
|||||||
|
|
||||||
boost::posix_time::ptime getLastWriteTime(void) const { return _fileLastWrite; }
|
boost::posix_time::ptime getLastWriteTime(void) const { return _fileLastWrite; }
|
||||||
const std::vector<unsigned char>& getChecksum(void) const { return _fileChecksum; }
|
const std::vector<unsigned char>& getChecksum(void) const { return _fileChecksum; }
|
||||||
|
bool hasCover(void) const { return _hasCover; }
|
||||||
|
|
||||||
template<class Action>
|
template<class Action>
|
||||||
void persist(Action& a)
|
void persist(Action& a)
|
||||||
@@ -148,6 +150,7 @@ class Track
|
|||||||
Wt::Dbo::field(a, _filePath, "path");
|
Wt::Dbo::field(a, _filePath, "path");
|
||||||
Wt::Dbo::field(a, _fileLastWrite, "last_write");
|
Wt::Dbo::field(a, _fileLastWrite, "last_write");
|
||||||
Wt::Dbo::field(a, _fileChecksum, "checksum");
|
Wt::Dbo::field(a, _fileChecksum, "checksum");
|
||||||
|
Wt::Dbo::field(a, _hasCover, "has_cover");
|
||||||
Wt::Dbo::hasMany(a, _genres, Wt::Dbo::ManyToMany, "track_genre", "", Wt::Dbo::OnDeleteCascade);
|
Wt::Dbo::hasMany(a, _genres, Wt::Dbo::ManyToMany, "track_genre", "", Wt::Dbo::OnDeleteCascade);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -167,6 +170,7 @@ class Track
|
|||||||
std::string _filePath;
|
std::string _filePath;
|
||||||
std::vector<unsigned char> _fileChecksum;
|
std::vector<unsigned char> _fileChecksum;
|
||||||
boost::posix_time::ptime _fileLastWrite;
|
boost::posix_time::ptime _fileLastWrite;
|
||||||
|
bool _hasCover;
|
||||||
|
|
||||||
Wt::Dbo::collection< Genre::pointer > _genres; // Tracks that belong to this genre
|
Wt::Dbo::collection< Genre::pointer > _genres; // Tracks that belong to this genre
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -29,7 +29,8 @@ Track::Track(const boost::filesystem::path& p)
|
|||||||
:
|
:
|
||||||
_trackNumber(0),
|
_trackNumber(0),
|
||||||
_discNumber(0),
|
_discNumber(0),
|
||||||
_filePath( p.string() )
|
_filePath( p.string() ),
|
||||||
|
_hasCover(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -114,6 +114,9 @@ AvFormat::parse(const boost::filesystem::path& p, Items& items)
|
|||||||
// Duration
|
// Duration
|
||||||
items.insert( std::make_pair(MetaData::Type::Duration, boost::posix_time::time_duration( boost::posix_time::seconds( input.getDurationSecs() )) ));
|
items.insert( std::make_pair(MetaData::Type::Duration, boost::posix_time::time_duration( boost::posix_time::seconds( input.getDurationSecs() )) ));
|
||||||
|
|
||||||
|
// Cover
|
||||||
|
items.insert( std::make_pair(MetaData::Type::HasCover, input.getNbPictures() > 0));
|
||||||
|
|
||||||
// Embedded MetaData
|
// Embedded MetaData
|
||||||
// Make sure to convert strings into UTF-8
|
// Make sure to convert strings into UTF-8
|
||||||
std::map<std::string, std::string>::const_iterator it;
|
std::map<std::string, std::string>::const_iterator it;
|
||||||
|
|||||||
@@ -39,18 +39,12 @@ namespace MetaData
|
|||||||
DiscNumber, // size_t
|
DiscNumber, // size_t
|
||||||
Date, // boost::posix_time::ptime
|
Date, // boost::posix_time::ptime
|
||||||
OriginalDate, // boost::posix_time::ptime
|
OriginalDate, // boost::posix_time::ptime
|
||||||
Cover, // GenericData
|
HasCover, // bool
|
||||||
AudioStreams, // vector<AudioStream>
|
AudioStreams, // vector<AudioStream>
|
||||||
VideoStreams, // vector<VideoStream>
|
VideoStreams, // vector<VideoStream>
|
||||||
SubtitleStreams, // vector<SubtitleStream>
|
SubtitleStreams, // vector<SubtitleStream>
|
||||||
};
|
};
|
||||||
|
|
||||||
// Used by Cover
|
|
||||||
struct GenericData {
|
|
||||||
std::string mimeType;
|
|
||||||
std::vector<unsigned char> data;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Used by Streams
|
// Used by Streams
|
||||||
struct AudioStream {
|
struct AudioStream {
|
||||||
std::size_t nbChannels;
|
std::size_t nbChannels;
|
||||||
|
|||||||
@@ -92,14 +92,25 @@ LmsApplication::LmsApplication(const Wt::WEnvironment& env, boost::filesystem::p
|
|||||||
|
|
||||||
// If here is no account in the database, launch the first connection wizard
|
// If here is no account in the database, launch the first connection wizard
|
||||||
if (firstConnection)
|
if (firstConnection)
|
||||||
|
createFirstConnectionUI();
|
||||||
|
else
|
||||||
|
createLmsUI();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
LmsApplication::createFirstConnectionUI()
|
||||||
{
|
{
|
||||||
// Hack, use the auth widget builtin strings
|
// Hack, use the auth widget builtin strings
|
||||||
builtinLocalizedStrings().useBuiltin(skeletons::AuthStrings_xml1);
|
builtinLocalizedStrings().useBuiltin(skeletons::AuthStrings_xml1);
|
||||||
|
|
||||||
root()->addWidget( new Settings::FirstConnectionFormView(_sessionData));
|
root()->addWidget( new Settings::FirstConnectionFormView(_sessionData));
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
void
|
||||||
|
LmsApplication::createLmsUI()
|
||||||
{
|
{
|
||||||
|
|
||||||
_sessionData.getDatabaseHandler().getLogin().changed().connect(this, &LmsApplication::handleAuthEvent);
|
_sessionData.getDatabaseHandler().getLogin().changed().connect(this, &LmsApplication::handleAuthEvent);
|
||||||
|
|
||||||
LmsAuth *authWidget = new LmsAuth(_sessionData.getDatabaseHandler());
|
LmsAuth *authWidget = new LmsAuth(_sessionData.getDatabaseHandler());
|
||||||
@@ -111,7 +122,6 @@ LmsApplication::LmsApplication(const Wt::WEnvironment& env, boost::filesystem::p
|
|||||||
|
|
||||||
root()->addWidget(authWidget);
|
root()->addWidget(authWidget);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
@@ -38,6 +38,8 @@ class LmsApplication : public Wt::WApplication
|
|||||||
private:
|
private:
|
||||||
|
|
||||||
void handleAuthEvent(void);
|
void handleAuthEvent(void);
|
||||||
|
void createFirstConnectionUI();
|
||||||
|
void createLmsUI();
|
||||||
|
|
||||||
SessionData _sessionData;
|
SessionData _sessionData;
|
||||||
|
|
||||||
|
|||||||
@@ -308,6 +308,16 @@
|
|||||||
${apply-info}
|
${apply-info}
|
||||||
</div>
|
</div>
|
||||||
</message>
|
</message>
|
||||||
|
|
||||||
|
<message id="mediaplayer-controls">
|
||||||
|
<div class="btn-group" role="group" aria-label="...">
|
||||||
|
${prev}
|
||||||
|
${play}
|
||||||
|
${pause}
|
||||||
|
${next}
|
||||||
|
</div>
|
||||||
|
</message>
|
||||||
|
|
||||||
</messages>
|
</messages>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ _playQueue(nullptr)
|
|||||||
filterLayout->addWidget(filterRelease);
|
filterLayout->addWidget(filterRelease);
|
||||||
_filterChain.addFilter(filterRelease);
|
_filterChain.addFilter(filterRelease);
|
||||||
|
|
||||||
mainLayout->addLayout(filterLayout, 0, 0);
|
mainLayout->addLayout(filterLayout, 0, 1);
|
||||||
// ENDOF(Filters)
|
// ENDOF(Filters)
|
||||||
|
|
||||||
// TODO ADD some stats (nb files, total duration, etc.)
|
// TODO ADD some stats (nb files, total duration, etc.)
|
||||||
@@ -83,7 +83,7 @@ _playQueue(nullptr)
|
|||||||
|
|
||||||
trackLayout->addLayout(trackControls);
|
trackLayout->addLayout(trackControls);
|
||||||
|
|
||||||
mainLayout->addLayout(trackLayout, 1, 0);
|
mainLayout->addLayout(trackLayout, 1, 1);
|
||||||
|
|
||||||
_filterChain.addFilter(_trackView);
|
_filterChain.addFilter(_trackView);
|
||||||
|
|
||||||
@@ -96,6 +96,11 @@ _playQueue(nullptr)
|
|||||||
|
|
||||||
Wt::WVBoxLayout* playQueueLayout = new Wt::WVBoxLayout();
|
Wt::WVBoxLayout* playQueueLayout = new Wt::WVBoxLayout();
|
||||||
|
|
||||||
|
_mediaPlayer = new AudioMediaPlayer();
|
||||||
|
playQueueLayout->addWidget(_mediaPlayer);
|
||||||
|
|
||||||
|
playQueueLayout->addWidget( _playQueue, 1);
|
||||||
|
|
||||||
Wt::WHBoxLayout* playlistControls = new Wt::WHBoxLayout();
|
Wt::WHBoxLayout* playlistControls = new Wt::WHBoxLayout();
|
||||||
|
|
||||||
Wt::WPushButton *saveBtn = new Wt::WPushButton("Save");
|
Wt::WPushButton *saveBtn = new Wt::WPushButton("Save");
|
||||||
@@ -140,17 +145,12 @@ _playQueue(nullptr)
|
|||||||
|
|
||||||
playQueueLayout->addLayout(playlistControls);
|
playQueueLayout->addLayout(playlistControls);
|
||||||
|
|
||||||
playQueueLayout->addWidget( _playQueue, 1);
|
mainLayout->addLayout(playQueueLayout, 0, 0, 2, 1);
|
||||||
|
|
||||||
mainLayout->addLayout(playQueueLayout, 0, 1, 2, 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_mediaPlayer = new AudioMediaPlayer();
|
|
||||||
mainLayout->addWidget(_mediaPlayer, 2, 0, 1, 2);
|
|
||||||
|
|
||||||
mainLayout->setRowStretch(1, 1);
|
mainLayout->setRowStretch(1, 1);
|
||||||
mainLayout->setRowResizable(0, true, Wt::WLength(200, Wt::WLength::Pixel));
|
mainLayout->setRowResizable(0, true, Wt::WLength(200, Wt::WLength::Pixel));
|
||||||
mainLayout->setColumnResizable(0, true);
|
mainLayout->setColumnResizable(0, true, Wt::WLength(400, Wt::WLength::Pixel));
|
||||||
|
|
||||||
// Double click on track
|
// Double click on track
|
||||||
// Set the selected tracks to the play queue
|
// Set the selected tracks to the play queue
|
||||||
|
|||||||
@@ -17,10 +17,12 @@
|
|||||||
* along with LMS. If not, see <http://www.gnu.org/licenses/>.
|
* along with LMS. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include <Wt/WMediaPlayer>
|
#include <Wt/WMediaPlayer>
|
||||||
#include <Wt/WProgressBar>
|
#include <Wt/WProgressBar>
|
||||||
#include <Wt/WCheckBox>
|
#include <Wt/WCheckBox>
|
||||||
|
#include <Wt/WTemplate>
|
||||||
|
#include <Wt/WHBoxLayout>
|
||||||
|
#include <Wt/WVBoxLayout>
|
||||||
|
|
||||||
#include "AudioMediaPlayer.hpp"
|
#include "AudioMediaPlayer.hpp"
|
||||||
|
|
||||||
@@ -30,50 +32,81 @@ AudioMediaPlayer::AudioMediaPlayer( Wt::WContainerWidget *parent)
|
|||||||
: Wt::WContainerWidget(parent),
|
: Wt::WContainerWidget(parent),
|
||||||
_mediaResource(nullptr)
|
_mediaResource(nullptr)
|
||||||
{
|
{
|
||||||
_mediaPlayer = new Wt::WMediaPlayer( Wt::WMediaPlayer::Audio, this );
|
this->setStyleClass("mediaplayer");
|
||||||
// _mediaPlayer->setAlternativeContent (new Wt::WText("You don't have HTML5 audio support!"));
|
this->setHeight(100);
|
||||||
// _mediaPlayer->setOptions( Wt::WMediaPlayer::Autoplay );
|
|
||||||
_mediaPlayer->addSource( Wt::WMediaPlayer::OGA, "" );
|
|
||||||
|
|
||||||
_mediaPlayer->ended().connect(this, &AudioMediaPlayer::handleTrackEnded);
|
Wt::WContainerWidget *sliderContainer = new Wt::WContainerWidget(this);
|
||||||
|
Wt::WHBoxLayout *sliderLayout = new Wt::WHBoxLayout();
|
||||||
|
sliderContainer->setLayout(sliderLayout);
|
||||||
|
|
||||||
{
|
sliderLayout->addWidget(_curTime = new Wt::WText("00:00:00"));
|
||||||
Wt::WContainerWidget *container = new Wt::WContainerWidget(this);
|
_curTime->setLineHeight(30);
|
||||||
|
sliderLayout->addWidget(_timeSlider = new Wt::WSlider( ), 1);
|
||||||
|
_timeSlider->setHeight(30);
|
||||||
|
sliderLayout->addWidget(_duration = new Wt::WText("00:00:00"));
|
||||||
|
_duration->setLineHeight(30);
|
||||||
|
|
||||||
Wt::WCheckBox *loop = new Wt::WCheckBox("Loop", this);
|
Wt::WContainerWidget *controlsContainer = new Wt::WContainerWidget(this);
|
||||||
|
Wt::WHBoxLayout *controlsLayout = new Wt::WHBoxLayout();
|
||||||
|
controlsContainer->setLayout(controlsLayout);
|
||||||
|
|
||||||
|
Wt::WContainerWidget *btnContainer = new Wt::WContainerWidget();
|
||||||
|
|
||||||
|
Wt::WTemplate *t = new Wt::WTemplate(Wt::WString::tr("mediaplayer-controls"), btnContainer);
|
||||||
|
|
||||||
|
Wt::WPushButton *prevBtn = new Wt::WPushButton("<<");
|
||||||
|
t->bindWidget("prev", prevBtn);
|
||||||
|
|
||||||
|
_playBtn = new Wt::WPushButton("Play");
|
||||||
|
t->bindWidget("play", _playBtn);
|
||||||
|
_playBtn->setWidth(70);
|
||||||
|
|
||||||
|
_pauseBtn = new Wt::WPushButton("Pause");
|
||||||
|
t->bindWidget("pause", _pauseBtn);
|
||||||
|
_pauseBtn->setWidth(70);
|
||||||
|
|
||||||
|
Wt::WPushButton *nextBtn = new Wt::WPushButton(">>");
|
||||||
|
t->bindWidget("next", nextBtn);
|
||||||
|
|
||||||
|
controlsLayout->addWidget(btnContainer);
|
||||||
|
|
||||||
|
_volumeSlider = new Wt::WSlider();
|
||||||
|
_volumeSlider->setRange(0,100);
|
||||||
|
_volumeSlider->setWidth(60);
|
||||||
|
_volumeSlider->setMinimumSize(60, Wt::WLength::Auto);
|
||||||
|
_volumeSlider->setHeight(30);
|
||||||
|
controlsLayout->addWidget(_volumeSlider);
|
||||||
|
|
||||||
|
/* Wt::WText* name = new Wt::WText("My track name");
|
||||||
|
controlsLayout->addWidget(name, 1);*/
|
||||||
|
|
||||||
|
Wt::WCheckBox *loop = new Wt::WCheckBox("Loop", controlsContainer);
|
||||||
loop->changed().connect(std::bind([=] ()
|
loop->changed().connect(std::bind([=] ()
|
||||||
{
|
{
|
||||||
_loop.emit( loop->checkState() == Wt::Checked);
|
_loop.emit( loop->checkState() == Wt::Checked);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
Wt::WCheckBox *shuffle = new Wt::WCheckBox("Shuffle", this);
|
Wt::WCheckBox *shuffle = new Wt::WCheckBox("Shuffle", controlsContainer);
|
||||||
shuffle->changed().connect(std::bind([=] ()
|
shuffle->changed().connect(std::bind([=] ()
|
||||||
{
|
{
|
||||||
_shuffle.emit( shuffle->checkState() == Wt::Checked);
|
_shuffle.emit( shuffle->checkState() == Wt::Checked);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
Wt::WPushButton *prevBtn = new Wt::WPushButton("<<", container );
|
controlsLayout->addWidget(loop);
|
||||||
_playBtn = new Wt::WPushButton("Play", container );
|
controlsLayout->addWidget(shuffle);
|
||||||
_pauseBtn = new Wt::WPushButton("Pause", container );
|
|
||||||
Wt::WPushButton *nextBtn = new Wt::WPushButton(">>", container );
|
|
||||||
|
|
||||||
_curTime = new Wt::WText(container);
|
_mediaPlayer = new Wt::WMediaPlayer( Wt::WMediaPlayer::Audio, this );
|
||||||
_timeSlider = new Wt::WSlider( container );
|
_mediaPlayer->addSource( Wt::WMediaPlayer::OGA, "" );
|
||||||
_duration = new Wt::WText(container);
|
_mediaPlayer->ended().connect(this, &AudioMediaPlayer::handleTrackEnded);
|
||||||
|
|
||||||
_volumeSlider = new Wt::WSlider( container );
|
_mediaPlayer->setControlsWidget( 0 );
|
||||||
_volumeSlider->setRange(0,100);
|
|
||||||
_volumeSlider->setValue(_mediaPlayer->volume() * 100);
|
|
||||||
|
|
||||||
_mediaPlayer->setControlsWidget( container );
|
|
||||||
_mediaPlayer->setButton(Wt::WMediaPlayer::Play, _playBtn);
|
_mediaPlayer->setButton(Wt::WMediaPlayer::Play, _playBtn);
|
||||||
_mediaPlayer->setButton(Wt::WMediaPlayer::Pause, _pauseBtn);
|
_mediaPlayer->setButton(Wt::WMediaPlayer::Pause, _pauseBtn);
|
||||||
|
|
||||||
_mediaPlayer->setText( Wt::WMediaPlayer::CurrentTime, _curTime);
|
|
||||||
_mediaPlayer->setText( Wt::WMediaPlayer::Duration, _duration);
|
|
||||||
|
|
||||||
_mediaPlayer->timeUpdated().connect(this, &AudioMediaPlayer::handleTimeUpdated);
|
_mediaPlayer->timeUpdated().connect(this, &AudioMediaPlayer::handleTimeUpdated);
|
||||||
|
|
||||||
|
_volumeSlider->setValue(_mediaPlayer->volume() * 100);
|
||||||
|
|
||||||
nextBtn->clicked().connect(std::bind([=] ()
|
nextBtn->clicked().connect(std::bind([=] ()
|
||||||
{
|
{
|
||||||
_mediaPlayer->stop();
|
_mediaPlayer->stop();
|
||||||
@@ -85,10 +118,8 @@ AudioMediaPlayer::AudioMediaPlayer( Wt::WContainerWidget *parent)
|
|||||||
_mediaPlayer->stop();
|
_mediaPlayer->stop();
|
||||||
_playPrevious.emit();
|
_playPrevious.emit();
|
||||||
}));
|
}));
|
||||||
}
|
|
||||||
|
|
||||||
_timeSlider->valueChanged().connect(this, &AudioMediaPlayer::handlePlayOffset);
|
_timeSlider->valueChanged().connect(this, &AudioMediaPlayer::handlePlayOffset);
|
||||||
_timeSlider->sliderMoved().connect(this, &AudioMediaPlayer::handleSliderMoved);
|
// _timeSlider->sliderMoved().connect(this, &AudioMediaPlayer::handleSliderMoved);
|
||||||
_timeSlider->setDisabled(true);
|
_timeSlider->setDisabled(true);
|
||||||
|
|
||||||
_volumeSlider->sliderMoved().connect(this, &AudioMediaPlayer::handleVolumeSliderMoved);
|
_volumeSlider->sliderMoved().connect(this, &AudioMediaPlayer::handleVolumeSliderMoved);
|
||||||
|
|||||||
+94
-47
@@ -20,35 +20,60 @@
|
|||||||
#include <boost/random/mersenne_twister.hpp>
|
#include <boost/random/mersenne_twister.hpp>
|
||||||
#include <boost/random/uniform_int_distribution.hpp>
|
#include <boost/random/uniform_int_distribution.hpp>
|
||||||
|
|
||||||
|
#include <Wt/WApplication>
|
||||||
|
#include <Wt/WImage>
|
||||||
|
#include <Wt/WLink>
|
||||||
#include <Wt/WItemDelegate>
|
#include <Wt/WItemDelegate>
|
||||||
|
#include <Wt/WStandardItem>
|
||||||
|
#include <Wt/WFileResource>
|
||||||
|
|
||||||
|
#include "resource/CoverResource.hpp"
|
||||||
|
|
||||||
#include "logger/Logger.hpp"
|
#include "logger/Logger.hpp"
|
||||||
|
|
||||||
#include "PlayQueue.hpp"
|
#include "PlayQueue.hpp"
|
||||||
|
|
||||||
namespace {
|
static const int CoverRole = Wt::UserRole + 1;
|
||||||
|
|
||||||
void modelForceRefreshDataRow(Wt::WStandardItemModel *model, int row)
|
namespace {
|
||||||
{
|
|
||||||
for (int i = 0; i < model->columnCount(); ++i)
|
|
||||||
model->setData(row, i, model->data(row, i));
|
|
||||||
}
|
|
||||||
|
|
||||||
void swapRows(Wt::WStandardItemModel *model, int row1, int row2)
|
void swapRows(Wt::WStandardItemModel *model, int row1, int row2)
|
||||||
{
|
{
|
||||||
// Copy column by column
|
LMS_LOG(MOD_UI, SEV_DEBUG) << "Swap called row1 = " << row1 << ", row2 = " << row2 << ", CoverRole = " << CoverRole;
|
||||||
|
|
||||||
|
// Swap data column by column
|
||||||
for (int i = 0; i < model->columnCount(); ++i)
|
for (int i = 0; i < model->columnCount(); ++i)
|
||||||
{
|
{
|
||||||
boost::any tmp = model->data(row1, i); // 1 -> tmp
|
Wt::WModelIndex index1 = model->index(row1, i);
|
||||||
model->setData(row1, i, model->data(row2, i)); // 2 -> 1
|
Wt::WModelIndex index2 = model->index(row2, i);
|
||||||
model->setData(row2, i, tmp); // tmp-> 2
|
|
||||||
}
|
{
|
||||||
|
auto tmp = model->itemData(index1); // 1 -> tmp
|
||||||
|
model->setItemData(index1, model->itemData(index2)); // 2 -> 1
|
||||||
|
model->setItemData(index2, tmp); // tmp-> 2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Workaround, do the same thing for the CoverRole
|
||||||
|
{
|
||||||
|
auto tmp = model->data(index1, CoverRole);
|
||||||
|
model->setData(index1, model->data(index2, CoverRole), CoverRole);
|
||||||
|
model->setData(index2, tmp, CoverRole);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace UserInterface {
|
namespace UserInterface {
|
||||||
|
|
||||||
|
enum ColumnId
|
||||||
|
{
|
||||||
|
COLUMN_ID_TRACK_ID = 0,
|
||||||
|
COLUMN_ID_POS = 1,
|
||||||
|
COLUMN_ID_COVER = 2,
|
||||||
|
COLUMN_ID_NAME = 3,
|
||||||
|
COLUMN_ID_DURATION = 4
|
||||||
|
};
|
||||||
|
|
||||||
static const int trackPosInvalid = -1;
|
static const int trackPosInvalid = -1;
|
||||||
|
|
||||||
class TrackSelector
|
class TrackSelector
|
||||||
@@ -59,8 +84,8 @@ class TrackSelector
|
|||||||
void setShuffle(bool enable);
|
void setShuffle(bool enable);
|
||||||
void setLoop(bool enable) { _loop = enable; }
|
void setLoop(bool enable) { _loop = enable; }
|
||||||
|
|
||||||
int getPrevious(void);
|
int previous(void);
|
||||||
int getNext(void);
|
int next(void);
|
||||||
int getCurrent(void);
|
int getCurrent(void);
|
||||||
|
|
||||||
// Set the internal pos thanks to the track pos
|
// Set the internal pos thanks to the track pos
|
||||||
@@ -86,6 +111,7 @@ class TrackSelector
|
|||||||
TrackSelector::TrackSelector()
|
TrackSelector::TrackSelector()
|
||||||
: _loop(false),
|
: _loop(false),
|
||||||
_shuffle(false),
|
_shuffle(false),
|
||||||
|
_size(0),
|
||||||
_curPos(0)
|
_curPos(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -102,7 +128,7 @@ TrackSelector::refreshPositions()
|
|||||||
_trackPos.push_back(i);
|
_trackPos.push_back(i);
|
||||||
|
|
||||||
// Now shuffle
|
// Now shuffle
|
||||||
// Perform size/2 permutations
|
// Source: http://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle
|
||||||
boost::random::mt19937 rng; // produces randomness out of thin air
|
boost::random::mt19937 rng; // produces randomness out of thin air
|
||||||
rng.seed(static_cast<unsigned int>(std::time(0)));
|
rng.seed(static_cast<unsigned int>(std::time(0)));
|
||||||
|
|
||||||
@@ -127,14 +153,18 @@ TrackSelector::setShuffle(bool enable)
|
|||||||
{
|
{
|
||||||
_shuffle = enable;
|
_shuffle = enable;
|
||||||
|
|
||||||
|
if (_size != 0)
|
||||||
|
{
|
||||||
|
// Update the current index we are playing if we switch shuffle
|
||||||
if (_shuffle)
|
if (_shuffle)
|
||||||
setPosByRowId(_curPos);
|
setPosByRowId(_curPos);
|
||||||
else
|
else
|
||||||
setPos(_trackPos[_curPos]);
|
setPos(_trackPos[_curPos]);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
TrackSelector::getNext()
|
TrackSelector::next()
|
||||||
{
|
{
|
||||||
if (_size == 0)
|
if (_size == 0)
|
||||||
return trackPosInvalid;
|
return trackPosInvalid;
|
||||||
@@ -153,7 +183,7 @@ TrackSelector::getNext()
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
TrackSelector::getPrevious()
|
TrackSelector::previous()
|
||||||
{
|
{
|
||||||
if (_size == 0)
|
if (_size == 0)
|
||||||
return trackPosInvalid;
|
return trackPosInvalid;
|
||||||
@@ -200,55 +230,64 @@ TrackSelector::setSize(std::size_t size)
|
|||||||
class PlayQueueItemDelegate : public Wt::WItemDelegate
|
class PlayQueueItemDelegate : public Wt::WItemDelegate
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PlayQueueItemDelegate(Wt::WObject *parent = 0) : Wt::WItemDelegate(parent), _selectedRowPos(trackPosInvalid) {}
|
PlayQueueItemDelegate(Wt::WObject *parent = 0) : Wt::WItemDelegate(parent) {}
|
||||||
|
|
||||||
void setSelectedRowPos(int rowPos) { _selectedRowPos = rowPos; }
|
|
||||||
|
|
||||||
Wt::WWidget* update(Wt::WWidget *widget, const Wt::WModelIndex &index, Wt::WFlags< Wt::ViewItemRenderFlag > flags)
|
Wt::WWidget* update(Wt::WWidget *widget, const Wt::WModelIndex &index, Wt::WFlags< Wt::ViewItemRenderFlag > flags)
|
||||||
{
|
{
|
||||||
Wt::WWidget* res = Wt::WItemDelegate::update(widget, index, flags);
|
Wt::WWidget* res;
|
||||||
|
|
||||||
if (res && index.isValid())
|
Wt::WString path = Wt::asString(index.data(CoverRole));
|
||||||
|
if (!path.empty())
|
||||||
{
|
{
|
||||||
if (_selectedRowPos != trackPosInvalid && index.row() == _selectedRowPos)
|
// Create an image for this track
|
||||||
res->toggleStyleClass("playqueue-playing", true);
|
Wt::WImage* image = new Wt::WImage( );
|
||||||
|
Wt::WResource* resource;
|
||||||
|
if (path != "none")
|
||||||
|
resource = new CoverResource(boost::filesystem::path(path.toUTF8()), 64, image);
|
||||||
else
|
else
|
||||||
res->toggleStyleClass("playqueue-playing", false);
|
resource = new Wt::WFileResource("image/jpeg", Wt::WApplication::instance()->docRoot() + "/images/unknown-cover.jpg", image);
|
||||||
|
|
||||||
|
image->setImageLink(Wt::WLink(resource));
|
||||||
|
|
||||||
|
res = image;
|
||||||
|
res->setObjectName("z");
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
res = Wt::WItemDelegate::update(widget, index, flags);
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
int _selectedRowPos;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
PlayQueue::PlayQueue(Database::Handler& db, Wt::WContainerWidget* parent)
|
PlayQueue::PlayQueue(Database::Handler& db, Wt::WContainerWidget* parent)
|
||||||
: Wt::WTableView(parent),
|
: Wt::WTableView(parent),
|
||||||
_db(db),
|
_db(db),
|
||||||
_curPlayedTrackPos(trackPosInvalid),
|
_curPlayedTrackPos(trackPosInvalid),
|
||||||
_trackSelector(new TrackSelector())
|
_trackSelector(new TrackSelector())
|
||||||
{
|
{
|
||||||
_model = new Wt::WStandardItemModel(0, 4, this);
|
_model = new Wt::WStandardItemModel(0, 5, this);
|
||||||
|
|
||||||
// 0 Column is hidden (track id)
|
// 0 Column is hidden (track id)
|
||||||
_model->setHeaderData(0, Wt::WString("#"));
|
_model->setHeaderData(COLUMN_ID_TRACK_ID, Wt::WString("#"));
|
||||||
_model->setHeaderData(1, Wt::WString("#"));
|
_model->setHeaderData(COLUMN_ID_POS, Wt::WString("#"));
|
||||||
_model->setHeaderData(2, Wt::WString("Track"));
|
_model->setHeaderData(COLUMN_ID_COVER, Wt::WString("Cover"));
|
||||||
_model->setHeaderData(3, Wt::WString("Duration"));
|
_model->setHeaderData(COLUMN_ID_NAME, Wt::WString("Track"));
|
||||||
|
_model->setHeaderData(COLUMN_ID_DURATION, Wt::WString("Duration"));
|
||||||
|
|
||||||
this->setModel(_model);
|
this->setModel(_model);
|
||||||
this->setSelectionMode(Wt::ExtendedSelection);
|
this->setSelectionMode(Wt::ExtendedSelection);
|
||||||
this->setSortingEnabled(false);
|
this->setSortingEnabled(false);
|
||||||
this->setAlternatingRowColors(true);
|
this->setAlternatingRowColors(true);
|
||||||
|
this->setRowHeight(64);
|
||||||
|
this->setColumnWidth(COLUMN_ID_COVER, 64);
|
||||||
|
this->setColumnWidth(COLUMN_ID_POS, 50);
|
||||||
|
this->setColumnWidth(COLUMN_ID_DURATION, 75);
|
||||||
|
|
||||||
this->setColumnWidth(0, 50);
|
this->setColumnHidden(COLUMN_ID_TRACK_ID, true);
|
||||||
this->setColumnWidth(1, 50);
|
|
||||||
|
|
||||||
this->setColumnHidden(0, true);
|
|
||||||
|
|
||||||
_itemDelegate = new PlayQueueItemDelegate();
|
_itemDelegate = new PlayQueueItemDelegate();
|
||||||
this->setItemDelegate(_itemDelegate);
|
this->setItemDelegate(_itemDelegate);
|
||||||
@@ -318,10 +357,11 @@ PlayQueue::addTracks(const std::vector<Database::Track::id_type>& trackIds)
|
|||||||
|
|
||||||
_model->insertRows(dataRow, 1);
|
_model->insertRows(dataRow, 1);
|
||||||
|
|
||||||
_model->setData(dataRow, 0, track.id());
|
_model->setData(dataRow, COLUMN_ID_TRACK_ID, track.id(), Wt::UserRole);
|
||||||
_model->setData(dataRow, 1, dataRow + 1);
|
_model->setData(dataRow, COLUMN_ID_POS, dataRow + 1);
|
||||||
_model->setData(dataRow, 2, track->getArtistName() + " - " + track->getName());
|
_model->setData(dataRow, COLUMN_ID_COVER, track->hasCover() ? track->getPath() : "none", CoverRole);
|
||||||
_model->setData(dataRow, 3, track->getDuration());
|
_model->setData(dataRow, COLUMN_ID_NAME, track->getArtistName() + " - " + track->getName());
|
||||||
|
_model->setData(dataRow, COLUMN_ID_DURATION, track->getDuration());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -351,7 +391,7 @@ PlayQueue::playNext(void)
|
|||||||
|
|
||||||
while (nbTries > 0)
|
while (nbTries > 0)
|
||||||
{
|
{
|
||||||
int pos = _trackSelector->getNext();
|
int pos = _trackSelector->next();
|
||||||
if (pos == trackPosInvalid)
|
if (pos == trackPosInvalid)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -369,7 +409,7 @@ PlayQueue::playPrevious(void)
|
|||||||
|
|
||||||
while (nbTries > 0)
|
while (nbTries > 0)
|
||||||
{
|
{
|
||||||
int pos = _trackSelector->getPrevious();
|
int pos = _trackSelector->previous();
|
||||||
if (pos == trackPosInvalid)
|
if (pos == trackPosInvalid)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -386,7 +426,7 @@ PlayQueue::readTrack(int rowPos)
|
|||||||
Wt::Dbo::Transaction transaction(_db.getSession());
|
Wt::Dbo::Transaction transaction(_db.getSession());
|
||||||
|
|
||||||
LMS_LOG(MOD_UI, SEV_DEBUG) << "Reading track at pos " << rowPos;
|
LMS_LOG(MOD_UI, SEV_DEBUG) << "Reading track at pos " << rowPos;
|
||||||
Database::Track::id_type trackId = boost::any_cast<Database::Track::id_type>(_model->data(rowPos, 0));
|
Database::Track::id_type trackId = boost::any_cast<Database::Track::id_type>(_model->data(rowPos, COLUMN_ID_TRACK_ID, Wt::UserRole));
|
||||||
|
|
||||||
Database::Track::pointer track = Database::Track::getById(_db.getSession(), trackId);
|
Database::Track::pointer track = Database::Track::getById(_db.getSession(), trackId);
|
||||||
if (track)
|
if (track)
|
||||||
@@ -395,6 +435,8 @@ PlayQueue::readTrack(int rowPos)
|
|||||||
|
|
||||||
_sigTrackPlay.emit(track->getPath());
|
_sigTrackPlay.emit(track->getPath());
|
||||||
|
|
||||||
|
this->scrollTo( _model->index(_trackSelector->getCurrent(), 0));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -407,15 +449,21 @@ PlayQueue::setPlayingTrackPos(int newRowPos)
|
|||||||
int oldRowPos = _curPlayedTrackPos;
|
int oldRowPos = _curPlayedTrackPos;
|
||||||
_curPlayedTrackPos = newRowPos;
|
_curPlayedTrackPos = newRowPos;
|
||||||
|
|
||||||
_itemDelegate->setSelectedRowPos(newRowPos);
|
|
||||||
|
|
||||||
// Hack re-set the data in order to trigger the rerending of the widget
|
// Hack re-set the data in order to trigger the rerending of the widget
|
||||||
// calling the update method of our custom item delegate gives bad results
|
// calling the update method of our custom item delegate gives bad results
|
||||||
if (oldRowPos >= 0)
|
if (oldRowPos >= 0)
|
||||||
modelForceRefreshDataRow(_model, oldRowPos);
|
{
|
||||||
|
_model->setData(oldRowPos, COLUMN_ID_POS, boost::any(), Wt::StyleClassRole);
|
||||||
|
_model->setData(oldRowPos, COLUMN_ID_NAME, boost::any(), Wt::StyleClassRole);
|
||||||
|
_model->setData(oldRowPos, COLUMN_ID_DURATION, boost::any(), Wt::StyleClassRole);
|
||||||
|
}
|
||||||
|
|
||||||
if (newRowPos >= 0)
|
if (newRowPos >= 0)
|
||||||
modelForceRefreshDataRow(_model, newRowPos);
|
{
|
||||||
|
_model->setData(newRowPos, COLUMN_ID_POS, "playqueue-playing", Wt::StyleClassRole);
|
||||||
|
_model->setData(newRowPos, COLUMN_ID_NAME, "playqueue-playing", Wt::StyleClassRole);
|
||||||
|
_model->setData(newRowPos, COLUMN_ID_DURATION, "playqueue-playing", Wt::StyleClassRole);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -432,7 +480,6 @@ PlayQueue::delSelected(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If the current played track is removed, make sure to unselect it
|
// If the current played track is removed, make sure to unselect it
|
||||||
_itemDelegate->setSelectedRowPos(trackPosInvalid);
|
|
||||||
_trackSelector->setSize(_model->rowCount());
|
_trackSelector->setSize(_model->rowCount());
|
||||||
|
|
||||||
renumber(minId, _model->rowCount() - 1);
|
renumber(minId, _model->rowCount() - 1);
|
||||||
|
|||||||
@@ -41,6 +41,8 @@ _field(field)
|
|||||||
this->setAlternatingRowColors(true);
|
this->setAlternatingRowColors(true);
|
||||||
this->setModel(&_queryModel);
|
this->setModel(&_queryModel);
|
||||||
|
|
||||||
|
this->setColumnWidth(1, 50);
|
||||||
|
|
||||||
this->selectionChanged().connect(this, &TableFilter::emitUpdate);
|
this->selectionChanged().connect(this, &TableFilter::emitUpdate);
|
||||||
|
|
||||||
setLayoutSizeAware(true);
|
setLayoutSizeAware(true);
|
||||||
@@ -66,14 +68,15 @@ _field(field)
|
|||||||
void
|
void
|
||||||
TableFilter::layoutSizeChanged (int width, int height)
|
TableFilter::layoutSizeChanged (int width, int height)
|
||||||
{
|
{
|
||||||
LMS_LOG(MOD_UI, SEV_DEBUG) << "LAYOUT CHANGED!";
|
LMS_LOG(MOD_UI, SEV_DEBUG) << "LAYOUT CHANGED, new width = " << width;
|
||||||
|
|
||||||
/* TODO
|
LMS_LOG(MOD_UI, SEV_DEBUG) << "Before: sizes = " << this->columnWidth(0).toPixels() << ", " << this->columnWidth(1).toPixels();
|
||||||
std::size_t trackColumnSize = this->columnWidth(1).toPixels() + 30 ;
|
|
||||||
|
std::size_t trackColumnSize = this->columnWidth(1).toPixels();
|
||||||
// Set the remaining size for the name column
|
// Set the remaining size for the name column
|
||||||
this->setColumnWidth(0, width - 7 - trackColumnSize);
|
this->setColumnWidth(0, width - trackColumnSize - (7 * 2) - 2);
|
||||||
*/
|
|
||||||
|
|
||||||
|
LMS_LOG(MOD_UI, SEV_DEBUG) << "After: sizes = " << this->columnWidth(0).toPixels() << ", " << this->columnWidth(1).toPixels();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set constraints on this filter
|
// Set constraints on this filter
|
||||||
|
|||||||
@@ -1,5 +1,25 @@
|
|||||||
|
.main-nav {
|
||||||
|
margin-bottom: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.Wt-hrh2 {
|
||||||
|
background-color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.Wt-vrh2 {
|
||||||
|
background-color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.contents {
|
||||||
|
padding: 0px 12px 6px;
|
||||||
|
}
|
||||||
|
|
||||||
.playqueue-playing {
|
.playqueue-playing {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.mediaplayer {
|
||||||
|
background-color: #ccc;
|
||||||
|
border-radius: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
Executable
BIN
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
@@ -0,0 +1,70 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2014 Emeric Poupon
|
||||||
|
*
|
||||||
|
* This file is part of LMS.
|
||||||
|
*
|
||||||
|
* LMS 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 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* LMS 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 LMS. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <boost/foreach.hpp>
|
||||||
|
|
||||||
|
#include <Wt/Http/Response>
|
||||||
|
|
||||||
|
#include "logger/Logger.hpp"
|
||||||
|
|
||||||
|
#include "cover/CoverArtGrabber.hpp"
|
||||||
|
|
||||||
|
#include "CoverResource.hpp"
|
||||||
|
|
||||||
|
namespace UserInterface {
|
||||||
|
|
||||||
|
CoverResource::CoverResource(const boost::filesystem::path& path, std::size_t size, Wt::WObject *parent)
|
||||||
|
: Wt::WResource(parent),
|
||||||
|
_path(path),
|
||||||
|
_size(size)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
CoverResource:: ~CoverResource()
|
||||||
|
{
|
||||||
|
beingDeleted();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
CoverResource::handleRequest(const Wt::Http::Request& request, Wt::Http::Response& response)
|
||||||
|
{
|
||||||
|
if (_data.empty())
|
||||||
|
{
|
||||||
|
std::vector<CoverArt::CoverArt> covers = CoverArt::Grabber::getFromTrack( _path );
|
||||||
|
|
||||||
|
BOOST_FOREACH(CoverArt::CoverArt& cover, covers)
|
||||||
|
{
|
||||||
|
cover.scale(_size);
|
||||||
|
_data = cover.getData();
|
||||||
|
_mimeType = cover.getMimeType();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO if not found fallback on an empty image
|
||||||
|
}
|
||||||
|
|
||||||
|
response.setMimeType(_mimeType);
|
||||||
|
|
||||||
|
for (unsigned int i = 0; i < _data.size(); ++i)
|
||||||
|
response.out().put(_data[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace UserInterface
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2014 Emeric Poupon
|
||||||
|
*
|
||||||
|
* This file is part of LMS.
|
||||||
|
*
|
||||||
|
* LMS 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 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* LMS 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 LMS. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <boost/foreach.hpp>
|
||||||
|
#include <boost/filesystem.hpp>
|
||||||
|
|
||||||
|
#include <Wt/WResource>
|
||||||
|
|
||||||
|
#include "database/AudioTypes.hpp"
|
||||||
|
|
||||||
|
namespace UserInterface {
|
||||||
|
|
||||||
|
class CoverResource : public Wt::WResource
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CoverResource(const boost::filesystem::path& p, // track to get cover from
|
||||||
|
std::size_t size, // size * size pixels
|
||||||
|
Wt::WObject *parent = 0);
|
||||||
|
~CoverResource();
|
||||||
|
|
||||||
|
void handleRequest(const Wt::Http::Request& request, Wt::Http::Response& response);
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
boost::filesystem::path _path;
|
||||||
|
std::size_t _size;
|
||||||
|
std::string _mimeType;
|
||||||
|
|
||||||
|
std::vector<unsigned char> _data;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace UserInterface
|
||||||
@@ -51,6 +51,7 @@ _sessionData(sessionData)
|
|||||||
contents->setStyleClass("contents");
|
contents->setStyleClass("contents");
|
||||||
contents->setOverflow(WContainerWidget::OverflowHidden);
|
contents->setOverflow(WContainerWidget::OverflowHidden);
|
||||||
|
|
||||||
|
// TODO menu style on hover
|
||||||
Wt::WMenu *menu = new Wt::WMenu(contents, Wt::Vertical);
|
Wt::WMenu *menu = new Wt::WMenu(contents, Wt::Vertical);
|
||||||
menu->setStyleClass("nav nav-pills nav-stacked submenu");
|
menu->setStyleClass("nav nav-pills nav-stacked submenu");
|
||||||
menu->setWidth(150);
|
menu->setWidth(150);
|
||||||
|
|||||||
Reference in New Issue
Block a user