From 3dc79838b5484aba0d805a3c5dac4c0e26503ac6 Mon Sep 17 00:00:00 2001 From: "Javier S. Pedro" Date: Wed, 28 Sep 2011 03:15:12 +0200 Subject: trying to fix more weird albumart behaviour --- qmafwwatchlet/qmafwwatchletplayer.cpp | 37 +++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 15 deletions(-) (limited to 'qmafwwatchlet/qmafwwatchletplayer.cpp') 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&)), this, SLOT(handleChangedMetadata(const QString&, const QList&))); 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 &l) { if (s == MAFW_METADATA_KEY_TITLE) { -- cgit v1.2.3