Read tumbnails from itdb tracks
This commit is contained in:
parent
71559bb125
commit
9ab2dde8ab
|
@ -26,6 +26,15 @@
|
|||
#include <taglib/fileref.h>
|
||||
#include <taglib/id3v1genres.h>
|
||||
|
||||
#ifdef HAVE_LIBGPOD
|
||||
# include <gdk-pixbuf/gdk-pixbuf.h>
|
||||
# include <gpod/itdb.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LIBMTP
|
||||
# include <libmtp.h>
|
||||
#endif
|
||||
|
||||
#include <QtGlobal>
|
||||
#include <QObject>
|
||||
#include <QFile>
|
||||
|
@ -46,14 +55,6 @@
|
|||
#include <QStandardPaths>
|
||||
#include <QtDebug>
|
||||
|
||||
#ifdef HAVE_LIBGPOD
|
||||
#include <gpod/itdb.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LIBMTP
|
||||
#include <libmtp.h>
|
||||
#endif
|
||||
|
||||
#include "core/logging.h"
|
||||
#include "core/messagehandler.h"
|
||||
#include "core/iconloader.h"
|
||||
|
@ -1061,7 +1062,7 @@ void Song::InitArtManual() {
|
|||
}
|
||||
|
||||
#ifdef HAVE_LIBGPOD
|
||||
void Song::InitFromItdb(const Itdb_Track *track, const QString &prefix) {
|
||||
void Song::InitFromItdb(Itdb_Track *track, const QString &prefix) {
|
||||
|
||||
d->valid_ = true;
|
||||
|
||||
|
@ -1104,6 +1105,22 @@ void Song::InitFromItdb(const Itdb_Track *track, const QString &prefix) {
|
|||
d->skipcount_ = track->skipcount;
|
||||
d->lastplayed_ = track->time_played;
|
||||
|
||||
if (itdb_track_has_thumbnails(track)) {
|
||||
GdkPixbuf *pixbuf = static_cast<GdkPixbuf*>(itdb_track_get_thumbnail(track, -1, -1));
|
||||
if (pixbuf) {
|
||||
gchar *buffer = nullptr;
|
||||
gsize buffer_size = 0;
|
||||
GError *error = nullptr;
|
||||
gdk_pixbuf_save_to_buffer(pixbuf, &buffer, &buffer_size, "jpeg", &error, nullptr);
|
||||
if (buffer) {
|
||||
const QByteArray data = QByteArray::fromRawData(buffer, buffer_size);
|
||||
d->image_.loadFromData(data, "JPEG");
|
||||
g_free(buffer);
|
||||
}
|
||||
g_object_unref(pixbuf);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void Song::ToItdb(Itdb_Track *track) const {
|
||||
|
|
|
@ -164,7 +164,7 @@ class Song {
|
|||
bool MergeFromSimpleMetaBundle(const Engine::SimpleMetaBundle &bundle);
|
||||
|
||||
#ifdef HAVE_LIBGPOD
|
||||
void InitFromItdb(const _Itdb_Track *track, const QString &prefix);
|
||||
void InitFromItdb(_Itdb_Track *track, const QString &prefix);
|
||||
void ToItdb(_Itdb_Track *track) const;
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Reference in New Issue