Use stream metadata
This commit is contained in:
parent
226bfb43ee
commit
98f23c3ddc
@ -36,6 +36,8 @@ void Player::EngineInitFinished() {
|
||||
|
||||
connect(engine_, SIGNAL(stateChanged(Engine::State)), SLOT(EngineStateChanged(Engine::State)));
|
||||
connect(engine_, SIGNAL(trackEnded()), SLOT(TrackEnded()));
|
||||
connect(engine_, SIGNAL(metaData(Engine::SimpleMetaBundle)),
|
||||
SLOT(EngineMetadataReceived(Engine::SimpleMetaBundle)));
|
||||
|
||||
emit InitFinished();
|
||||
}
|
||||
@ -192,3 +194,14 @@ void Player::Seek(int seconds) {
|
||||
|
||||
engine_->seek(seconds * 1000);
|
||||
}
|
||||
|
||||
void Player::EngineMetadataReceived(const Engine::SimpleMetaBundle& bundle) {
|
||||
PlaylistItem* item = playlist_->current_item();
|
||||
if (item == NULL)
|
||||
return;
|
||||
|
||||
Song song;
|
||||
song.InitFromSimpleMetaBundle(bundle);
|
||||
|
||||
playlist_->SetStreamMetadata(item->Url(), song);
|
||||
}
|
||||
|
@ -55,6 +55,7 @@ class Player : public QObject {
|
||||
private slots:
|
||||
void EngineInitFinished();
|
||||
void EngineStateChanged(Engine::State);
|
||||
void EngineMetadataReceived(const Engine::SimpleMetaBundle& bundle);
|
||||
|
||||
private:
|
||||
Playlist* playlist_;
|
||||
|
@ -23,8 +23,7 @@ void RadioPlaylistItem::Save(QSettings& settings) const {
|
||||
settings.setValue("service", service_->name());
|
||||
settings.setValue("url", url_.toString());
|
||||
settings.setValue("title", title_);
|
||||
if (!artist_.isEmpty())
|
||||
settings.setValue("artist", artist_);
|
||||
settings.setValue("artist", artist_);
|
||||
}
|
||||
|
||||
void RadioPlaylistItem::Restore(const QSettings& settings) {
|
||||
|
16
src/song.cpp
16
src/song.cpp
@ -20,6 +20,7 @@
|
||||
#include <QVariant>
|
||||
|
||||
#include "trackslider.h"
|
||||
#include "enginebase.h"
|
||||
|
||||
const char* Song::kColumnSpec =
|
||||
"title, album, artist, albumartist, composer, "
|
||||
@ -221,6 +222,21 @@ void Song::InitFromLastFM(const lastfm::Track& track) {
|
||||
d->length_ = track.duration();
|
||||
}
|
||||
|
||||
void Song::InitFromSimpleMetaBundle(const Engine::SimpleMetaBundle &bundle) {
|
||||
d->valid_ = true;
|
||||
|
||||
d->title_ = bundle.title;
|
||||
d->artist_ = bundle.artist;
|
||||
d->album_ = bundle.album;
|
||||
d->comment_ = bundle.comment;
|
||||
d->genre_ = bundle.genre;
|
||||
d->bitrate_ = bundle.bitrate.toInt();
|
||||
d->samplerate_ = bundle.samplerate.toInt();
|
||||
d->length_ = bundle.length.toInt();
|
||||
d->year_ = bundle.year.toInt();
|
||||
d->track_ = bundle.tracknr.toInt();
|
||||
}
|
||||
|
||||
void Song::BindToQuery(QSqlQuery *query) const {
|
||||
#define intval(x) (x == -1 ? QVariant() : x)
|
||||
|
||||
|
@ -7,6 +7,8 @@
|
||||
#include <QSharedData>
|
||||
#include <QSharedDataPointer>
|
||||
|
||||
#include "engine_fwd.h"
|
||||
|
||||
namespace lastfm {
|
||||
class Track;
|
||||
}
|
||||
@ -54,6 +56,7 @@ class Song {
|
||||
void InitFromFile(const QString& filename, int directory_id);
|
||||
void InitFromQuery(const QSqlQuery& query);
|
||||
void InitFromLastFM(const lastfm::Track& track);
|
||||
void InitFromSimpleMetaBundle(const Engine::SimpleMetaBundle& bundle);
|
||||
|
||||
// Save
|
||||
void BindToQuery(QSqlQuery* query) const;
|
||||
|
Loading…
x
Reference in New Issue
Block a user