summaryrefslogtreecommitdiff
path: root/qmafwwatchlet/qmafwwatchletplayer.cpp
diff options
context:
space:
mode:
authorJavier S. Pedro <maemo@javispedro.com>2011-09-28 03:15:12 +0200
committerJavier S. Pedro <maemo@javispedro.com>2011-09-28 03:15:12 +0200
commit3dc79838b5484aba0d805a3c5dac4c0e26503ac6 (patch)
tree71e0eb5f8fa22953a0b024b96447e04393c91fd9 /qmafwwatchlet/qmafwwatchletplayer.cpp
parent253c1cd0b9b61b67e3456dab6f3272208b4fb115 (diff)
downloadsowatch-3dc79838b5484aba0d805a3c5dac4c0e26503ac6.tar.gz
sowatch-3dc79838b5484aba0d805a3c5dac4c0e26503ac6.zip
trying to fix more weird albumart behaviour
Diffstat (limited to 'qmafwwatchlet/qmafwwatchletplayer.cpp')
-rw-r--r--qmafwwatchlet/qmafwwatchletplayer.cpp37
1 files changed, 22 insertions, 15 deletions
diff --git a/qmafwwatchlet/qmafwwatchletplayer.cpp b/qmafwwatchlet/qmafwwatchletplayer.cpp
index d4f9686..cc63508 100644
--- a/qmafwwatchlet/qmafwwatchletplayer.cpp
+++ b/qmafwwatchlet/qmafwwatchletplayer.cpp
@@ -16,7 +16,7 @@ QMafwWatchletPlayer::QMafwWatchletPlayer(QMafwWatchlet* watchlet) :
_active(false),
_renderer(0),
_state(MafwRenderer::Stopped),
- _title(tr("No media")),
+ _title(),
_album(),
_artist(),
_rendererArt(),
@@ -90,7 +90,6 @@ void QMafwWatchletPlayer::stop()
void QMafwWatchletPlayer::next()
{
if (!_renderer) return;
- qDebug() << "next";
_renderer->next();
}
@@ -118,25 +117,22 @@ void QMafwWatchletPlayer::setRenderer(MafwRenderer * renderer)
{
if (_renderer && _active) {
disconnect(_renderer, 0, this, 0);
- }
- _renderer = renderer;
- reconnect();
- if (!_renderer && _active) {
- _title = tr("No media");
- emit titleChanged();
+ _title.clear();
_album.clear();
- emit albumChanged();
_artist.clear();
- emit artistChanged();
- _rendererArt.clear();
- _mediaArt.clear();
- emit mediaArtChanged();
+ handleMediaChange();
+ emit titleChanged();
+ updateMediaArt();
}
+ _renderer = renderer;
+ reconnect();
}
void QMafwWatchletPlayer::reconnect()
{
if (_renderer && _active) {
+ connect(_renderer, SIGNAL(mediaChanged(int, const MafwContent&)),
+ this, SLOT(handleMediaChange()));
connect(_renderer, SIGNAL(metadataChanged(const QString&, const QList<QVariant>&)),
this, SLOT(handleChangedMetadata(const QString&, const QList<QVariant>&)));
connect(_renderer, SIGNAL(stateChanged(MafwRenderer::State)),
@@ -155,6 +151,11 @@ QString QMafwWatchletPlayer::stripAlbumArtComponent(const QString& component)
static QRegExp stripB("^[()_{}[]!@#$^&*+=|\\\\/\"'?<>~`\\s\\t]*");
static QRegExp stripE("[()_{}[]!@#$^&*+=|\\\\/\"'?<>~`\\s\\t]*$");
QString s(component);
+
+ if (s.isEmpty()) {
+ return QString(" ");
+ }
+
s = s.replace(rsb, "");
s = s.replace(rfb, "");
s = s.replace(rrb, "");
@@ -162,8 +163,8 @@ QString QMafwWatchletPlayer::stripAlbumArtComponent(const QString& component)
s = s.replace(stripE, "");
s = s.replace(" ", " ");
s = s.replace("\t", " ");
- s = s.toLower();
- return s;
+
+ return s.toLower();
}
QString QMafwWatchletPlayer::mediaArtPath() const
@@ -209,6 +210,12 @@ void QMafwWatchletPlayer::updateMediaArt()
}
}
+void QMafwWatchletPlayer::handleMediaChange()
+{
+ // Sometimes qmafw does not send the renderer-art metadata, so we assume it's been cleared here.
+ _rendererArt.clear();
+}
+
void QMafwWatchletPlayer::handleChangedMetadata(const QString &s, const QList<QVariant> &l)
{
if (s == MAFW_METADATA_KEY_TITLE) {