summaryrefslogtreecommitdiff
path: root/qmafwwatchlet
diff options
context:
space:
mode:
authorJavier S. Pedro <maemo@javispedro.com>2011-09-28 02:36:03 +0200
committerJavier S. Pedro <maemo@javispedro.com>2011-09-28 02:36:03 +0200
commit1050c062eee192c62dec2b3f1d35f663ef7ef607 (patch)
tree7b5a4677c304b81cc0bd4e5516daff00450cb471 /qmafwwatchlet
parent64662ecc6ea6b5296ea77d83eac6eb1372afac01 (diff)
downloadsowatch-1050c062eee192c62dec2b3f1d35f663ef7ef607.tar.gz
sowatch-1050c062eee192c62dec2b3f1d35f663ef7ef607.zip
fixing a few mediaart qmafwwatchlet bugs
Diffstat (limited to 'qmafwwatchlet')
-rw-r--r--qmafwwatchlet/metawatch-digital.qml2
-rw-r--r--qmafwwatchlet/qmafwwatchletplayer.cpp76
-rw-r--r--qmafwwatchlet/qmafwwatchletplayer.h11
3 files changed, 67 insertions, 22 deletions
diff --git a/qmafwwatchlet/metawatch-digital.qml b/qmafwwatchlet/metawatch-digital.qml
index 0ec07cd..22c7833 100644
--- a/qmafwwatchlet/metawatch-digital.qml
+++ b/qmafwwatchlet/metawatch-digital.qml
@@ -10,7 +10,7 @@ Rectangle {
anchors.fill: parent
fillMode: Image.PreserveAspectFit
smooth: true
- source: player.imageUrl
+ source: player.mediaArt
}
Rectangle {
diff --git a/qmafwwatchlet/qmafwwatchletplayer.cpp b/qmafwwatchlet/qmafwwatchletplayer.cpp
index 018795a..d4f9686 100644
--- a/qmafwwatchlet/qmafwwatchletplayer.cpp
+++ b/qmafwwatchlet/qmafwwatchletplayer.cpp
@@ -18,7 +18,9 @@ QMafwWatchletPlayer::QMafwWatchletPlayer(QMafwWatchlet* watchlet) :
_state(MafwRenderer::Stopped),
_title(tr("No media")),
_album(),
- _imageUrl()
+ _artist(),
+ _rendererArt(),
+ _mediaArt()
{
Q_ASSERT(watchlet);
}
@@ -38,9 +40,9 @@ QString QMafwWatchletPlayer::artist() const
return _artist;
}
-QUrl QMafwWatchletPlayer::imageUrl() const
+QUrl QMafwWatchletPlayer::mediaArt() const
{
- return _imageUrl;
+ return _mediaArt;
}
void QMafwWatchletPlayer::activate()
@@ -120,10 +122,15 @@ void QMafwWatchletPlayer::setRenderer(MafwRenderer * renderer)
_renderer = renderer;
reconnect();
if (!_renderer && _active) {
- _imageUrl.clear();
_title = tr("No media");
- emit imageUrlChanged();
emit titleChanged();
+ _album.clear();
+ emit albumChanged();
+ _artist.clear();
+ emit artistChanged();
+ _rendererArt.clear();
+ _mediaArt.clear();
+ emit mediaArtChanged();
}
}
@@ -167,7 +174,7 @@ QString QMafwWatchletPlayer::mediaArtPath() const
QByteArray first_hash = QCryptographicHash::hash(artist.toUtf8(), QCryptographicHash::Md5).toHex();
QByteArray second_hash = QCryptographicHash::hash(album.toUtf8(), QCryptographicHash::Md5).toHex();
QString file = QString("album-%1-%2.jpeg").arg(first_hash.constData()).arg(second_hash.constData());
- qDebug() << "testing" << file;
+ qDebug() << "checking for albumart in" << file;
if (dir.exists(file)) {
return dir.absoluteFilePath(file);
}
@@ -175,7 +182,7 @@ QString QMafwWatchletPlayer::mediaArtPath() const
artist = " ";
first_hash = QCryptographicHash::hash(artist.toUtf8(), QCryptographicHash::Md5).toHex();
file = QString("album-%1-%2.jpeg").arg(first_hash.constData()).arg(second_hash.constData());
- qDebug() << "testing" << file;
+ qDebug() << "checking for albumart in" << file;
if (dir.exists(file)) {
return dir.absoluteFilePath(file);
}
@@ -183,24 +190,57 @@ QString QMafwWatchletPlayer::mediaArtPath() const
return QString();
}
+void QMafwWatchletPlayer::updateMediaArt()
+{
+ QUrl newArt;
+
+ if (!_rendererArt.isEmpty()) {
+ newArt = QUrl::fromLocalFile(_rendererArt);
+ } else {
+ QString path = mediaArtPath();
+ if (!path.isEmpty()) {
+ newArt = QUrl::fromLocalFile(path);
+ }
+ }
+
+ if (newArt != _mediaArt) {
+ _mediaArt = newArt;
+ emit mediaArtChanged();
+ }
+}
+
void QMafwWatchletPlayer::handleChangedMetadata(const QString &s, const QList<QVariant> &l)
{
- if (l.isEmpty()) return;
if (s == MAFW_METADATA_KEY_TITLE) {
- _title = l[0].toString();
+ if (!l.isEmpty()) {
+ _title = l[0].toString();
+ } else {
+ _title.clear();
+ }
emit titleChanged();
} else if (s == MAFW_METADATA_KEY_ALBUM) {
- _album = l[0].toString();
+ if (!l.isEmpty()) {
+ _album = l[0].toString();
+ } else {
+ _album.clear();
+ }
emit albumChanged();
- _imageUrl = QUrl::fromLocalFile(mediaArtPath());
- qDebug() << "got image url (album)" << _album << _imageUrl;
- emit imageUrlChanged();
+ updateMediaArt();
} else if (s == MAFW_METADATA_KEY_ARTIST) {
- _artist = l[0].toString();
+ if (!l.isEmpty()) {
+ _artist = l[0].toString();
+ } else {
+ _artist.clear();
+ }
emit artistChanged();
- _imageUrl = QUrl::fromLocalFile(mediaArtPath());
- qDebug() << "got image url (artist)" << _album << _imageUrl;
- emit imageUrlChanged();
+ updateMediaArt();
+ } else if (s == MAFW_METADATA_KEY_RENDERER_ART_URI) {
+ if (!l.isEmpty()) {
+ _rendererArt = l[0].toString();
+ } else {
+ _rendererArt.clear();
+ }
+ updateMediaArt();
}
}
@@ -214,6 +254,8 @@ void QMafwWatchletPlayer::handleMediaInfo(const MafwMediaInfo &info)
const QMap<QString, QList<QVariant> > & data = info.metaData();
handleChangedMetadata(MAFW_METADATA_KEY_TITLE, data[MAFW_METADATA_KEY_TITLE]);
handleChangedMetadata(MAFW_METADATA_KEY_ALBUM, data[MAFW_METADATA_KEY_ALBUM]);
+ handleChangedMetadata(MAFW_METADATA_KEY_ARTIST, data[MAFW_METADATA_KEY_ARTIST]);
+ handleChangedMetadata(MAFW_METADATA_KEY_RENDERER_ART_URI, data[MAFW_METADATA_KEY_RENDERER_ART_URI]);
}
void QMafwWatchletPlayer::doVolumeUp(const QString& name, const QVariant& value)
diff --git a/qmafwwatchlet/qmafwwatchletplayer.h b/qmafwwatchlet/qmafwwatchletplayer.h
index d85f38c..4a587a6 100644
--- a/qmafwwatchlet/qmafwwatchletplayer.h
+++ b/qmafwwatchlet/qmafwwatchletplayer.h
@@ -7,6 +7,7 @@
#include <MafwRenderer.h>
#include <MafwMediaInfo.h>
+#include <MafwContent.h>
namespace sowatch
{
@@ -19,7 +20,7 @@ class QMafwWatchletPlayer : public QObject
Q_PROPERTY(QString title READ title NOTIFY titleChanged)
Q_PROPERTY(QString album READ album NOTIFY albumChanged)
Q_PROPERTY(QString artist READ artist NOTIFY artistChanged)
- Q_PROPERTY(QUrl imageUrl READ imageUrl NOTIFY imageUrlChanged)
+ Q_PROPERTY(QUrl mediaArt READ mediaArt NOTIFY mediaArtChanged)
public:
explicit QMafwWatchletPlayer(QMafwWatchlet* watchlet);
@@ -27,13 +28,13 @@ public:
QString title() const;
QString album() const;
QString artist() const;
- QUrl imageUrl() const;
+ QUrl mediaArt() const;
signals:
void titleChanged();
void albumChanged();
void artistChanged();
- void imageUrlChanged();
+ void mediaArtChanged();
public slots:
void activate();
@@ -56,13 +57,15 @@ private:
QString _title;
QString _album;
QString _artist;
- QUrl _imageUrl;
+ QString _rendererArt;
+ QUrl _mediaArt;
void setRenderer(MafwRenderer*);
void reconnect();
static QString stripAlbumArtComponent(const QString& component);
QString mediaArtPath() const;
+ void updateMediaArt();
private slots:
void handleChangedMetadata(const QString& s, const QList<QVariant>& l);