Set metadata from deezer engine
This commit is contained in:
parent
0f4ffe4fce
commit
3e9530fa8d
@ -1002,12 +1002,14 @@ void Song::MergeFromSimpleMetaBundle(const Engine::SimpleMetaBundle &bundle) {
|
||||
if (!bundle.album.isEmpty()) d->album_ = bundle.album;
|
||||
if (!bundle.comment.isEmpty()) d->comment_ = bundle.comment;
|
||||
if (!bundle.genre.isEmpty()) d->genre_ = bundle.genre;
|
||||
if (bundle.bitrate > 0) d->bitrate_ = bundle.bitrate;
|
||||
if (bundle.samplerate > 0) d->samplerate_ = bundle.samplerate;
|
||||
if (bundle.bitdepth > 0) d->samplerate_ = bundle.bitdepth;
|
||||
if (bundle.length > 0) set_length_nanosec(bundle.length);
|
||||
if (bundle.year > 0) d->year_ = bundle.year;
|
||||
if (bundle.tracknr > 0) d->track_ = bundle.tracknr;
|
||||
if (bundle.filetype != FileType_Unknown) d->filetype_ = bundle.filetype;
|
||||
if (bundle.samplerate > 0) d->samplerate_ = bundle.samplerate;
|
||||
if (bundle.bitdepth > 0) d->samplerate_ = bundle.bitdepth;
|
||||
if (bundle.bitrate > 0) d->bitrate_ = bundle.bitrate;
|
||||
if (!bundle.lyrics.isEmpty()) d->lyrics_ = bundle.lyrics;
|
||||
|
||||
}
|
||||
|
||||
|
@ -28,6 +28,8 @@
|
||||
|
||||
#include <deezer/deezer-connect.h>
|
||||
#include <deezer/deezer-player.h>
|
||||
#include <deezer/deezer-object.h>
|
||||
#include <deezer/deezer-track.h>
|
||||
|
||||
#include <QtGlobal>
|
||||
#include <QCoreApplication>
|
||||
@ -40,6 +42,7 @@
|
||||
#include "core/timeconstants.h"
|
||||
#include "core/taskmanager.h"
|
||||
#include "core/logging.h"
|
||||
#include "core/song.h"
|
||||
#include "engine_fwd.h"
|
||||
#include "enginebase.h"
|
||||
#include "enginetype.h"
|
||||
@ -122,7 +125,7 @@ bool DeezerEngine::Init() {
|
||||
if (dzerr != DZ_ERROR_NO_ERROR) {
|
||||
qLog(Error) << "Deezer: Failed to activate player.";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
dzerr = dz_player_set_event_cb(player_, PlayerEventCallback);
|
||||
if (dzerr != DZ_ERROR_NO_ERROR) {
|
||||
@ -471,5 +474,38 @@ void DeezerEngine::PlayerProgressCallback(dz_player_handle handle, dz_useconds_t
|
||||
}
|
||||
|
||||
void DeezerEngine::PlayerMetaDataCallback(dz_player_handle handle, dz_track_metadata_handle metadata, void *userdata) {
|
||||
//DeezerEngine *engine = reinterpret_cast<DeezerEngine*>(userdata);
|
||||
|
||||
const dz_media_track_detailed_infos_t *track_metadata = dz_track_metadata_get_format_header(metadata);
|
||||
DeezerEngine *engine = reinterpret_cast<DeezerEngine*>(userdata);
|
||||
Engine::SimpleMetaBundle bundle;
|
||||
|
||||
switch (track_metadata->format) {
|
||||
case DZ_MEDIA_FORMAT_AUDIO_MPEG:
|
||||
bundle.filetype = Song::FileType_MPEG;
|
||||
break;
|
||||
case DZ_MEDIA_FORMAT_AUDIO_FLAC:
|
||||
bundle.filetype = Song::FileType_FLAC;
|
||||
break;
|
||||
case DZ_MEDIA_FORMAT_AUDIO_PCM:
|
||||
bundle.filetype = Song::FileType_PCM;
|
||||
return;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
bundle.url = engine->original_url_;
|
||||
bundle.title = QString();
|
||||
bundle.artist = QString();
|
||||
bundle.comment = QString();
|
||||
bundle.album = QString();
|
||||
bundle.length = 0;
|
||||
bundle.year = 0;
|
||||
bundle.tracknr = 0;
|
||||
bundle.samplerate = track_metadata->audio.samples.sample_rate;
|
||||
bundle.bitdepth = 0;
|
||||
bundle.bitrate = track_metadata->average_bitrate / 1000;
|
||||
bundle.lyrics = QString();
|
||||
|
||||
emit engine->MetaData(bundle);
|
||||
|
||||
}
|
||||
|
@ -42,6 +42,7 @@
|
||||
#include "engine_fwd.h"
|
||||
#include "enginetype.h"
|
||||
#include "enginedevice.h"
|
||||
#include "core/song.h"
|
||||
|
||||
namespace Engine {
|
||||
|
||||
@ -212,6 +213,7 @@ struct SimpleMetaBundle {
|
||||
qlonglong length;
|
||||
int year;
|
||||
int tracknr;
|
||||
Song::FileType filetype;
|
||||
int samplerate;
|
||||
int bitdepth;
|
||||
qlonglong bitrate;
|
||||
|
@ -592,6 +592,7 @@ void GstEnginePipeline::TagMessageReceived(GstMessage *msg) {
|
||||
bundle.length = 0;
|
||||
bundle.year = 0;
|
||||
bundle.tracknr = 0;
|
||||
bundle.filetype = Song::FileType_Unknown;
|
||||
bundle.samplerate = 0;
|
||||
bundle.bitdepth = 0;
|
||||
bundle.bitrate = ParseUIntTag(taglist, GST_TAG_BITRATE) / 1000;
|
||||
|
@ -1464,7 +1464,12 @@ void Playlist::SetStreamMetadata(const QUrl &url, const Song &song) {
|
||||
if (current_item()->Url() != url) return;
|
||||
|
||||
// Don't update the metadata if it's only a minor change from before
|
||||
if (current_item()->Metadata().artist() == song.artist() && current_item()->Metadata().title() == song.title() && current_item()->Metadata().album() == song.album()) return;
|
||||
if (
|
||||
current_item()->Metadata().filetype() == song.filetype() &&
|
||||
current_item()->Metadata().artist() == song.artist() &&
|
||||
current_item()->Metadata().title() == song.title() &&
|
||||
current_item()->Metadata().album() == song.album()
|
||||
) return;
|
||||
|
||||
// TODO: Update context & playlist if changed, but don't show popup.
|
||||
//(song.bitrate() <= 0 || current_item()->Metadata().bitrate() == song.bitrate())
|
||||
|
Loading…
x
Reference in New Issue
Block a user