diff options
Diffstat (limited to 'qmafwwatchlet/qmafwwatchletplayer.h')
-rw-r--r-- | qmafwwatchlet/qmafwwatchletplayer.h | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/qmafwwatchlet/qmafwwatchletplayer.h b/qmafwwatchlet/qmafwwatchletplayer.h new file mode 100644 index 0000000..d85f38c --- /dev/null +++ b/qmafwwatchlet/qmafwwatchletplayer.h @@ -0,0 +1,81 @@ +#ifndef QMAFWWATCHLETPLAYER_H +#define QMAFWWATCHLETPLAYER_H + +#include <QtCore/QUrl> + +#include <sowatch.h> + +#include <MafwRenderer.h> +#include <MafwMediaInfo.h> + +namespace sowatch +{ + +class QMafwWatchlet; + +class QMafwWatchletPlayer : public QObject +{ + Q_OBJECT + 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) + +public: + explicit QMafwWatchletPlayer(QMafwWatchlet* watchlet); + + QString title() const; + QString album() const; + QString artist() const; + QUrl imageUrl() const; + +signals: + void titleChanged(); + void albumChanged(); + void artistChanged(); + void imageUrlChanged(); + +public slots: + void activate(); + void deactivate(); + + void playPause(); + void play(); + void pause(); + void stop(); + void next(); + void previous(); + + void volumeUp(); + void volumeDown(); + +private: + bool _active; + MafwRenderer* _renderer; + MafwRenderer::State _state; + QString _title; + QString _album; + QString _artist; + QUrl _imageUrl; + + void setRenderer(MafwRenderer*); + void reconnect(); + + static QString stripAlbumArtComponent(const QString& component); + QString mediaArtPath() const; + +private slots: + void handleChangedMetadata(const QString& s, const QList<QVariant>& l); + void handleChangedState(MafwRenderer::State state); + void handleMediaInfo(const MafwMediaInfo& info); + void doVolumeUp(const QString& name, const QVariant& value); + void doVolumeDown(const QString& name, const QVariant& value); + + friend class QMafwWatchlet; +}; + +} + +QML_DECLARE_TYPE(sowatch::QMafwWatchletPlayer) + +#endif // QMAFWWATCHLETPLAYER_H |