Merge branch 'develop'
This commit is contained in:
@@ -101,7 +101,7 @@ InputFormatContext::findStreamInfo(void)
|
|||||||
std::size_t
|
std::size_t
|
||||||
InputFormatContext::getDurationSecs() const
|
InputFormatContext::getDurationSecs() const
|
||||||
{
|
{
|
||||||
if (native()->duration != AV_NOPTS_VALUE )
|
if (static_cast<int>(native()->duration) != AV_NOPTS_VALUE )
|
||||||
return native()->duration / AV_TIME_BASE;
|
return native()->duration / AV_TIME_BASE;
|
||||||
else
|
else
|
||||||
return 0; // TODO, do something better?
|
return 0; // TODO, do something better?
|
||||||
@@ -128,18 +128,39 @@ InputFormatContext::getNbPictures(void) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
InputFormatContext::getPictures(std::vector< std::vector<unsigned char> >& pictures) const
|
InputFormatContext::getPictures(std::vector<Picture>& pictures) const
|
||||||
{
|
{
|
||||||
|
static const std::map<int, std::string> codecMimeMap =
|
||||||
|
{
|
||||||
|
{ AV_CODEC_ID_BMP, "image/x-bmp" },
|
||||||
|
{ AV_CODEC_ID_GIF, "image/gif" },
|
||||||
|
{ AV_CODEC_ID_MJPEG, "image/jpeg" },
|
||||||
|
{ AV_CODEC_ID_PNG, "image/png" },
|
||||||
|
{ AV_CODEC_ID_PNG, "image/x-png" },
|
||||||
|
{ AV_CODEC_ID_PPM, "image/x-portable-pixmap" },
|
||||||
|
};
|
||||||
|
|
||||||
for (std::size_t i = 0; i < native()->nb_streams; ++i)
|
for (std::size_t i = 0; i < native()->nb_streams; ++i)
|
||||||
{
|
{
|
||||||
if (native()->streams[i]->disposition & AV_DISPOSITION_ATTACHED_PIC)
|
Stream stream(native()->streams[i]);
|
||||||
|
|
||||||
|
if (stream.hasAttachedPic())
|
||||||
{
|
{
|
||||||
|
Picture picture;
|
||||||
|
|
||||||
|
auto itMime = codecMimeMap.find(stream.getCodecContext().getCodecId());
|
||||||
|
if (itMime != codecMimeMap.end())
|
||||||
|
picture.mimeType = itMime->second;
|
||||||
|
else
|
||||||
|
picture.mimeType = "application/octet-stream";
|
||||||
|
|
||||||
|
LMS_LOG(MOD_AV, SEV_DEBUG) << "MIME set to '" << picture.mimeType << "'" << std::endl;
|
||||||
|
|
||||||
AVPacket pkt = native()->streams[i]->attached_pic;
|
AVPacket pkt = native()->streams[i]->attached_pic;
|
||||||
|
|
||||||
std::vector<unsigned char> data;
|
std::copy(pkt.data, pkt.data + pkt.size, std::back_inserter(picture.data));
|
||||||
std::copy(pkt.data, pkt.data + pkt.size, std::back_inserter(data));
|
|
||||||
|
|
||||||
pictures.push_back( data );
|
pictures.push_back( picture );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,6 +31,11 @@
|
|||||||
namespace Av
|
namespace Av
|
||||||
{
|
{
|
||||||
|
|
||||||
|
struct Picture {
|
||||||
|
std::string mimeType;
|
||||||
|
std::vector<unsigned char> data;
|
||||||
|
};
|
||||||
|
|
||||||
class InputFormatContext : public FormatContext
|
class InputFormatContext : public FormatContext
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -47,7 +52,7 @@ class InputFormatContext : public FormatContext
|
|||||||
|
|
||||||
// Get attached pictures
|
// Get attached pictures
|
||||||
std::size_t getNbPictures(void) const;
|
std::size_t getNbPictures(void) const;
|
||||||
void getPictures(std::vector< std::vector<unsigned char> >& pictures) const;
|
void getPictures(std::vector<Picture>& pictures) const;
|
||||||
|
|
||||||
// Get the streams
|
// Get the streams
|
||||||
std::vector<Stream> getStreams(void);
|
std::vector<Stream> getStreams(void);
|
||||||
|
|||||||
@@ -37,11 +37,11 @@ Grabber::getFromInputFormatContext(const Av::InputFormatContext& input)
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
std::vector< std::vector<unsigned char> > pictures;
|
std::vector<Av::Picture> pictures;
|
||||||
input.getPictures(pictures);
|
input.getPictures(pictures);
|
||||||
|
|
||||||
BOOST_FOREACH(const std::vector<unsigned char>& picture, pictures)
|
BOOST_FOREACH(const Av::Picture& picture, pictures)
|
||||||
res.push_back( CoverArt("application/octet-stream", picture) );
|
res.push_back( CoverArt(picture.mimeType, picture.data) );
|
||||||
|
|
||||||
}
|
}
|
||||||
catch(std::exception& e)
|
catch(std::exception& e)
|
||||||
|
|||||||
+12
-2
@@ -73,9 +73,11 @@ _playQueue(nullptr)
|
|||||||
Wt::WHBoxLayout* trackControls = new Wt::WHBoxLayout();
|
Wt::WHBoxLayout* trackControls = new Wt::WHBoxLayout();
|
||||||
|
|
||||||
Wt::WPushButton* playBtn = new Wt::WPushButton("Play");
|
Wt::WPushButton* playBtn = new Wt::WPushButton("Play");
|
||||||
|
playBtn->setStyleClass("btn-sm");
|
||||||
trackControls->addWidget(playBtn);
|
trackControls->addWidget(playBtn);
|
||||||
|
|
||||||
Wt::WPushButton* addBtn = new Wt::WPushButton("Add");
|
Wt::WPushButton* addBtn = new Wt::WPushButton("Add");
|
||||||
|
addBtn->setStyleClass("btn-sm");
|
||||||
trackControls->addWidget(addBtn);
|
trackControls->addWidget(addBtn);
|
||||||
trackControls->addWidget(new Wt::WText("Total duration: "), 1);
|
trackControls->addWidget(new Wt::WText("Total duration: "), 1);
|
||||||
|
|
||||||
@@ -93,8 +95,10 @@ _playQueue(nullptr)
|
|||||||
Wt::Dbo::Transaction transaction(_db.getSession());
|
Wt::Dbo::Transaction transaction(_db.getSession());
|
||||||
Database::User::pointer user = _db.getCurrentUser();
|
Database::User::pointer user = _db.getCurrentUser();
|
||||||
|
|
||||||
|
Wt::WContainerWidget* playQueueContainer = new Wt::WContainerWidget();
|
||||||
|
playQueueContainer->setStyleClass("playqueue");
|
||||||
Wt::WVBoxLayout* playQueueLayout = new Wt::WVBoxLayout();
|
Wt::WVBoxLayout* playQueueLayout = new Wt::WVBoxLayout();
|
||||||
playQueueLayout->setContentsMargins(5,5,5,5);
|
playQueueContainer->setLayout(playQueueLayout);
|
||||||
|
|
||||||
_mediaPlayer = new AudioMediaPlayer();
|
_mediaPlayer = new AudioMediaPlayer();
|
||||||
playQueueLayout->addWidget(_mediaPlayer);
|
playQueueLayout->addWidget(_mediaPlayer);
|
||||||
@@ -104,15 +108,21 @@ _playQueue(nullptr)
|
|||||||
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");
|
||||||
|
saveBtn->setStyleClass("btn-sm");
|
||||||
|
|
||||||
playlistControls->addWidget(saveBtn);
|
playlistControls->addWidget(saveBtn);
|
||||||
Wt::WPushButton *loadBtn = new Wt::WPushButton("Load");
|
Wt::WPushButton *loadBtn = new Wt::WPushButton("Load");
|
||||||
|
loadBtn->setStyleClass("btn-sm");
|
||||||
playlistControls->addWidget(loadBtn);
|
playlistControls->addWidget(loadBtn);
|
||||||
|
|
||||||
Wt::WPushButton *upBtn = new Wt::WPushButton("UP");
|
Wt::WPushButton *upBtn = new Wt::WPushButton("UP");
|
||||||
|
upBtn->setStyleClass("btn-sm");
|
||||||
playlistControls->addWidget(upBtn);
|
playlistControls->addWidget(upBtn);
|
||||||
Wt::WPushButton *downBtn = new Wt::WPushButton("DO");
|
Wt::WPushButton *downBtn = new Wt::WPushButton("DO");
|
||||||
|
downBtn->setStyleClass("btn-sm");
|
||||||
playlistControls->addWidget(downBtn);
|
playlistControls->addWidget(downBtn);
|
||||||
Wt::WPushButton *delBtn = new Wt::WPushButton("DEL");
|
Wt::WPushButton *delBtn = new Wt::WPushButton("DEL");
|
||||||
|
delBtn->setStyleClass("btn-sm");
|
||||||
playlistControls->addWidget(delBtn);
|
playlistControls->addWidget(delBtn);
|
||||||
|
|
||||||
delBtn->clicked().connect(_playQueue, &PlayQueue::delSelected);
|
delBtn->clicked().connect(_playQueue, &PlayQueue::delSelected);
|
||||||
@@ -145,7 +155,7 @@ _playQueue(nullptr)
|
|||||||
|
|
||||||
playQueueLayout->addLayout(playlistControls);
|
playQueueLayout->addLayout(playlistControls);
|
||||||
|
|
||||||
mainLayout->addLayout(playQueueLayout, 0, 0, 2, 1);
|
mainLayout->addWidget(playQueueContainer, 0, 0, 2, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
mainLayout->setRowStretch(1, 1);
|
mainLayout->setRowStretch(1, 1);
|
||||||
|
|||||||
+58
-39
@@ -26,6 +26,7 @@
|
|||||||
#include <Wt/WItemDelegate>
|
#include <Wt/WItemDelegate>
|
||||||
#include <Wt/WStandardItem>
|
#include <Wt/WStandardItem>
|
||||||
#include <Wt/WFileResource>
|
#include <Wt/WFileResource>
|
||||||
|
#include <Wt/WTheme>
|
||||||
|
|
||||||
#include "resource/CoverResource.hpp"
|
#include "resource/CoverResource.hpp"
|
||||||
|
|
||||||
@@ -33,32 +34,25 @@
|
|||||||
|
|
||||||
#include "PlayQueue.hpp"
|
#include "PlayQueue.hpp"
|
||||||
|
|
||||||
static const int CoverRole = Wt::UserRole + 1;
|
static const int NameRole = Wt::UserRole;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
void swapRows(Wt::WStandardItemModel *model, int row1, int row2)
|
void swapRows(Wt::WStandardItemModel *model, int row1, int row2)
|
||||||
{
|
{
|
||||||
LMS_LOG(MOD_UI, SEV_DEBUG) << "Swap called row1 = " << row1 << ", row2 = " << row2 << ", CoverRole = " << CoverRole;
|
|
||||||
|
|
||||||
// Swap data column by column
|
// Swap data column by column
|
||||||
for (int i = 0; i < model->columnCount(); ++i)
|
for (int i = 0; i < model->columnCount(); ++i)
|
||||||
{
|
{
|
||||||
Wt::WModelIndex index1 = model->index(row1, i);
|
Wt::WModelIndex index1 = model->index(row1, i);
|
||||||
Wt::WModelIndex index2 = model->index(row2, i);
|
Wt::WModelIndex index2 = model->index(row2, i);
|
||||||
|
|
||||||
|
// swap data associated with standard roles
|
||||||
{
|
{
|
||||||
auto tmp = model->itemData(index1); // 1 -> tmp
|
auto tmp = model->itemData(index1); // 1 -> tmp
|
||||||
model->setItemData(index1, model->itemData(index2)); // 2 -> 1
|
model->setItemData(index1, model->itemData(index2)); // 2 -> 1
|
||||||
model->setItemData(index2, tmp); // tmp-> 2
|
model->setItemData(index2, tmp); // tmp-> 2
|
||||||
}
|
}
|
||||||
|
// caution: swap data associated with our custom roles if any!!
|
||||||
// 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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -68,10 +62,8 @@ namespace UserInterface {
|
|||||||
enum ColumnId
|
enum ColumnId
|
||||||
{
|
{
|
||||||
COLUMN_ID_TRACK_ID = 0,
|
COLUMN_ID_TRACK_ID = 0,
|
||||||
COLUMN_ID_POS = 1,
|
COLUMN_ID_COVER = 1,
|
||||||
COLUMN_ID_COVER = 2,
|
COLUMN_ID_NAME = 2,
|
||||||
COLUMN_ID_NAME = 3,
|
|
||||||
COLUMN_ID_DURATION = 4
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static const int trackPosInvalid = -1;
|
static const int trackPosInvalid = -1;
|
||||||
@@ -227,6 +219,12 @@ TrackSelector::setSize(std::size_t size)
|
|||||||
refreshPositions();
|
refreshPositions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct Name
|
||||||
|
{
|
||||||
|
Wt::WString track;
|
||||||
|
Wt::WString artist;
|
||||||
|
};
|
||||||
|
|
||||||
class PlayQueueItemDelegate : public Wt::WItemDelegate
|
class PlayQueueItemDelegate : public Wt::WItemDelegate
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -236,21 +234,30 @@ class PlayQueueItemDelegate : public Wt::WItemDelegate
|
|||||||
{
|
{
|
||||||
Wt::WWidget* res;
|
Wt::WWidget* res;
|
||||||
|
|
||||||
Wt::WString path = Wt::asString(index.data(CoverRole));
|
if (!index.data(NameRole).empty())
|
||||||
if (!path.empty())
|
|
||||||
{
|
{
|
||||||
// Create an image for this track
|
Name name = boost::any_cast<Name>(index.data(NameRole));
|
||||||
Wt::WImage* image = new Wt::WImage( );
|
|
||||||
Wt::WResource* resource;
|
|
||||||
if (path != "none")
|
|
||||||
resource = new CoverResource(boost::filesystem::path(path.toUTF8()), 64, image);
|
|
||||||
else
|
|
||||||
resource = new Wt::WFileResource("image/jpeg", Wt::WApplication::instance()->docRoot() + "/images/unknown-cover.jpg", image);
|
|
||||||
|
|
||||||
image->setImageLink(Wt::WLink(resource));
|
Wt::WContainerWidget *container = new Wt::WContainerWidget();
|
||||||
|
Wt::WText* track = new Wt::WText(name.track, Wt::PlainText, container);
|
||||||
|
Wt::WText* artist = new Wt::WText(name.artist, Wt::PlainText, container);
|
||||||
|
|
||||||
res = image;
|
artist->setInline(false);
|
||||||
res->setObjectName("z");
|
track->setInline(false);
|
||||||
|
|
||||||
|
artist->setStyleClass("playqueue-artist");
|
||||||
|
track->setStyleClass("playqueue-track");
|
||||||
|
|
||||||
|
// Apply style if any
|
||||||
|
Wt::WString styleClass = Wt::asString(index.data(Wt::StyleClassRole));
|
||||||
|
|
||||||
|
// Apply selection style if any
|
||||||
|
if (flags & Wt::RenderSelected)
|
||||||
|
styleClass += " " + Wt::WApplication::instance()->theme()->activeClass();
|
||||||
|
|
||||||
|
container->setStyleClass(styleClass);
|
||||||
|
|
||||||
|
res = container;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
res = Wt::WItemDelegate::update(widget, index, flags);
|
res = Wt::WItemDelegate::update(widget, index, flags);
|
||||||
@@ -269,14 +276,12 @@ _db(db),
|
|||||||
_curPlayedTrackPos(trackPosInvalid),
|
_curPlayedTrackPos(trackPosInvalid),
|
||||||
_trackSelector(new TrackSelector())
|
_trackSelector(new TrackSelector())
|
||||||
{
|
{
|
||||||
_model = new Wt::WStandardItemModel(0, 5, this);
|
_model = new Wt::WStandardItemModel(0, 3, this);
|
||||||
|
|
||||||
// 0 Column is hidden (track id)
|
// 0 Column is hidden (track id)
|
||||||
_model->setHeaderData(COLUMN_ID_TRACK_ID, Wt::WString("#"));
|
_model->setHeaderData(COLUMN_ID_TRACK_ID, Wt::WString("#"));
|
||||||
_model->setHeaderData(COLUMN_ID_POS, Wt::WString("#"));
|
|
||||||
_model->setHeaderData(COLUMN_ID_COVER, Wt::WString("Cover"));
|
_model->setHeaderData(COLUMN_ID_COVER, Wt::WString("Cover"));
|
||||||
_model->setHeaderData(COLUMN_ID_NAME, Wt::WString("Track"));
|
_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);
|
||||||
@@ -284,8 +289,9 @@ _trackSelector(new TrackSelector())
|
|||||||
this->setAlternatingRowColors(true);
|
this->setAlternatingRowColors(true);
|
||||||
this->setRowHeight(64);
|
this->setRowHeight(64);
|
||||||
this->setColumnWidth(COLUMN_ID_COVER, 64);
|
this->setColumnWidth(COLUMN_ID_COVER, 64);
|
||||||
this->setColumnWidth(COLUMN_ID_POS, 50);
|
this->setColumnWidth(COLUMN_ID_NAME, 240);
|
||||||
this->setColumnWidth(COLUMN_ID_DURATION, 75);
|
|
||||||
|
this->setLayoutSizeAware(true);
|
||||||
|
|
||||||
this->setColumnHidden(COLUMN_ID_TRACK_ID, true);
|
this->setColumnHidden(COLUMN_ID_TRACK_ID, true);
|
||||||
|
|
||||||
@@ -308,6 +314,15 @@ _trackSelector(new TrackSelector())
|
|||||||
|
|
||||||
}, std::placeholders::_1, std::placeholders::_2));
|
}, std::placeholders::_1, std::placeholders::_2));
|
||||||
|
|
||||||
|
_coverResource = new CoverResource(db, 64);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
PlayQueue::layoutSizeChanged (int width, int height)
|
||||||
|
{
|
||||||
|
std::size_t coverColumnSize = this->columnWidth(COLUMN_ID_COVER).toPixels();
|
||||||
|
// Set the remaining size for the name column
|
||||||
|
this->setColumnWidth(COLUMN_ID_NAME, width - coverColumnSize - (7 * 2) - 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -358,10 +373,18 @@ PlayQueue::addTracks(const std::vector<Database::Track::id_type>& trackIds)
|
|||||||
_model->insertRows(dataRow, 1);
|
_model->insertRows(dataRow, 1);
|
||||||
|
|
||||||
_model->setData(dataRow, COLUMN_ID_TRACK_ID, track.id(), Wt::UserRole);
|
_model->setData(dataRow, COLUMN_ID_TRACK_ID, track.id(), Wt::UserRole);
|
||||||
_model->setData(dataRow, COLUMN_ID_POS, dataRow + 1);
|
|
||||||
_model->setData(dataRow, COLUMN_ID_COVER, track->hasCover() ? track->getPath() : "none", CoverRole);
|
std::string coverUrl;
|
||||||
_model->setData(dataRow, COLUMN_ID_NAME, track->getArtistName() + " - " + track->getName());
|
if (track->hasCover())
|
||||||
_model->setData(dataRow, COLUMN_ID_DURATION, track->getDuration());
|
coverUrl = _coverResource->url() + "&coverid=" + Wt::asString(track.id()).toUTF8();
|
||||||
|
else
|
||||||
|
coverUrl = "images/unknown-cover.jpg";
|
||||||
|
_model->setData(dataRow, COLUMN_ID_COVER, coverUrl, Wt::DecorationRole);
|
||||||
|
|
||||||
|
Name name;
|
||||||
|
name.track = Wt::WString::fromUTF8(track->getName());
|
||||||
|
name.artist = Wt::WString::fromUTF8(track->getArtistName());
|
||||||
|
_model->setData(dataRow, COLUMN_ID_NAME, name, NameRole);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -453,16 +476,12 @@ PlayQueue::setPlayingTrackPos(int newRowPos)
|
|||||||
// 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)
|
||||||
{
|
{
|
||||||
_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_NAME, boost::any(), Wt::StyleClassRole);
|
||||||
_model->setData(oldRowPos, COLUMN_ID_DURATION, boost::any(), Wt::StyleClassRole);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newRowPos >= 0)
|
if (newRowPos >= 0)
|
||||||
{
|
{
|
||||||
_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_NAME, "playqueue-playing", Wt::StyleClassRole);
|
||||||
_model->setData(newRowPos, COLUMN_ID_DURATION, "playqueue-playing", Wt::StyleClassRole);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,6 +26,8 @@
|
|||||||
#include "database/DatabaseHandler.hpp"
|
#include "database/DatabaseHandler.hpp"
|
||||||
#include "database/AudioTypes.hpp"
|
#include "database/AudioTypes.hpp"
|
||||||
|
|
||||||
|
#include "resource/CoverResource.hpp"
|
||||||
|
|
||||||
namespace UserInterface {
|
namespace UserInterface {
|
||||||
|
|
||||||
class PlayQueueItemDelegate;
|
class PlayQueueItemDelegate;
|
||||||
@@ -64,6 +66,8 @@ class PlayQueue : public Wt::WTableView
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
void layoutSizeChanged (int width, int height);
|
||||||
|
|
||||||
bool readTrack(int rowId);
|
bool readTrack(int rowId);
|
||||||
void setPlayingTrackPos(int newRowPos);
|
void setPlayingTrackPos(int newRowPos);
|
||||||
void renumber(int firstId, int lastId);
|
void renumber(int firstId, int lastId);
|
||||||
@@ -76,6 +80,8 @@ class PlayQueue : public Wt::WTableView
|
|||||||
|
|
||||||
PlayQueueItemDelegate* _itemDelegate;
|
PlayQueueItemDelegate* _itemDelegate;
|
||||||
|
|
||||||
|
CoverResource* _coverResource;
|
||||||
|
|
||||||
int _curPlayedTrackPos;
|
int _curPlayedTrackPos;
|
||||||
std::unique_ptr<TrackSelector> _trackSelector;
|
std::unique_ptr<TrackSelector> _trackSelector;
|
||||||
|
|
||||||
|
|||||||
@@ -14,10 +14,34 @@ div.contents {
|
|||||||
padding: 0px 12px 6px;
|
padding: 0px 12px 6px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.playqueue {
|
||||||
|
background-color: #BBB;
|
||||||
|
border-radius: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
.playqueue-playing {
|
.playqueue-playing {
|
||||||
|
background-color: rgba(202, 167, 66, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.Wt-tableview .playqueue-playing {
|
||||||
|
color: #FFF;
|
||||||
|
}
|
||||||
|
|
||||||
|
.Wt-tableview .Wt-tv-contents.Wt-striped div.playqueue-playing:nth-child(odd) {
|
||||||
|
background-color: rgba(202, 167, 66, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.playqueue-track {
|
||||||
|
margin-top: 12px;
|
||||||
|
line-height: normal;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.playqueue-artist {
|
||||||
|
line-height: normal;
|
||||||
|
font-style: italic;
|
||||||
|
}
|
||||||
|
|
||||||
.mediaplayer {
|
.mediaplayer {
|
||||||
background-color: #ccc;
|
background-color: #ccc;
|
||||||
border-radius: 10px;
|
border-radius: 10px;
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
#include <boost/foreach.hpp>
|
#include <boost/foreach.hpp>
|
||||||
|
|
||||||
|
#include <Wt/WApplication>
|
||||||
#include <Wt/Http/Response>
|
#include <Wt/Http/Response>
|
||||||
|
|
||||||
#include "logger/Logger.hpp"
|
#include "logger/Logger.hpp"
|
||||||
@@ -29,9 +30,9 @@
|
|||||||
|
|
||||||
namespace UserInterface {
|
namespace UserInterface {
|
||||||
|
|
||||||
CoverResource::CoverResource(const boost::filesystem::path& path, std::size_t size, Wt::WObject *parent)
|
CoverResource::CoverResource(Database::Handler& db, std::size_t size, Wt::WObject *parent)
|
||||||
: Wt::WResource(parent),
|
: Wt::WResource(parent),
|
||||||
_path(path),
|
_db(db),
|
||||||
_size(size)
|
_size(size)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -45,25 +46,50 @@ CoverResource:: ~CoverResource()
|
|||||||
void
|
void
|
||||||
CoverResource::handleRequest(const Wt::Http::Request& request, Wt::Http::Response& response)
|
CoverResource::handleRequest(const Wt::Http::Request& request, Wt::Http::Response& response)
|
||||||
{
|
{
|
||||||
if (_data.empty())
|
// Get the id of the track
|
||||||
|
const std::string *trackIdStr = request.getParameter("coverid");
|
||||||
|
|
||||||
|
if (trackIdStr)
|
||||||
{
|
{
|
||||||
std::vector<CoverArt::CoverArt> covers = CoverArt::Grabber::getFromTrack( _path );
|
Database::Track::id_type trackId;
|
||||||
|
{
|
||||||
|
std::istringstream iss(*trackIdStr); iss >> trackId;
|
||||||
|
}
|
||||||
|
|
||||||
|
Wt::Dbo::Transaction transaction(_db.getSession());
|
||||||
|
|
||||||
|
Database::Track::pointer track = Database::Track::getById(_db.getSession(), trackId);
|
||||||
|
std::vector<CoverArt::CoverArt> covers = CoverArt::Grabber::getFromTrack(track);
|
||||||
|
|
||||||
|
transaction.commit();
|
||||||
|
|
||||||
BOOST_FOREACH(CoverArt::CoverArt& cover, covers)
|
BOOST_FOREACH(CoverArt::CoverArt& cover, covers)
|
||||||
{
|
{
|
||||||
cover.scale(_size);
|
if (cover.scale(_size))
|
||||||
_data = cover.getData();
|
{
|
||||||
_mimeType = cover.getMimeType();
|
response.setMimeType( cover.getMimeType() );
|
||||||
break;
|
|
||||||
|
BOOST_FOREACH(unsigned char c, cover.getData())
|
||||||
|
response.out().put( c );
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
// TODO if not found fallback on an empty image
|
LMS_LOG(MOD_UI, SEV_DEBUG) << "Resize error for track id = " << trackId;
|
||||||
}
|
}
|
||||||
|
LMS_LOG(MOD_UI, SEV_DEBUG) << "no valid cover found for track id = " << trackId;
|
||||||
|
{
|
||||||
|
std::ifstream ist(Wt::WApplication::instance()->docRoot() + "/images/unknown-cover.jpg");
|
||||||
|
|
||||||
response.setMimeType(_mimeType);
|
char c;
|
||||||
|
while(ist.get(c))
|
||||||
|
response.out().put( c );
|
||||||
|
|
||||||
for (unsigned int i = 0; i < _data.size(); ++i)
|
response.setMimeType("image/jpeg");
|
||||||
response.out().put(_data[i]);
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
LMS_LOG(MOD_UI, SEV_DEBUG) << "no cover id parameter";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -17,11 +17,15 @@
|
|||||||
* along with LMS. If not, see <http://www.gnu.org/licenses/>.
|
* along with LMS. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifndef COVER_RESOURCE_HPP_
|
||||||
|
#define COVER_RESOURCE_HPP_
|
||||||
|
|
||||||
#include <boost/foreach.hpp>
|
#include <boost/foreach.hpp>
|
||||||
#include <boost/filesystem.hpp>
|
#include <boost/filesystem.hpp>
|
||||||
|
|
||||||
#include <Wt/WResource>
|
#include <Wt/WResource>
|
||||||
|
|
||||||
|
#include "database/DatabaseHandler.hpp"
|
||||||
#include "database/AudioTypes.hpp"
|
#include "database/AudioTypes.hpp"
|
||||||
|
|
||||||
namespace UserInterface {
|
namespace UserInterface {
|
||||||
@@ -29,7 +33,7 @@ namespace UserInterface {
|
|||||||
class CoverResource : public Wt::WResource
|
class CoverResource : public Wt::WResource
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CoverResource(const boost::filesystem::path& p, // track to get cover from
|
CoverResource(Database::Handler& db,
|
||||||
std::size_t size, // size * size pixels
|
std::size_t size, // size * size pixels
|
||||||
Wt::WObject *parent = 0);
|
Wt::WObject *parent = 0);
|
||||||
~CoverResource();
|
~CoverResource();
|
||||||
@@ -38,13 +42,10 @@ class CoverResource : public Wt::WResource
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
boost::filesystem::path _path;
|
Database::Handler& _db;
|
||||||
std::size_t _size;
|
std::size_t _size;
|
||||||
std::string _mimeType;
|
|
||||||
|
|
||||||
std::vector<unsigned char> _data;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} // namespace UserInterface
|
} // namespace UserInterface
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user