summaryrefslogtreecommitdiff
path: root/qmafwwatchlet/qmafwwatchletplayer.h
blob: d85f38c8d5d71ef972d7cf3a98c39ae1d2792fdf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
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