summaryrefslogtreecommitdiff
path: root/qmafwwatchlet/qmafwwatchletplayer.h
blob: 625635c356fd8ff961d081eb8115b860a9d571c2 (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
82
83
84
85
86
#ifndef QMAFWWATCHLETPLAYER_H
#define QMAFWWATCHLETPLAYER_H

#include <QtCore/QUrl>

#include <sowatch.h>

#include <MafwRenderer.h>
#include <MafwMediaInfo.h>
#include <MafwContent.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 mediaArt READ mediaArt NOTIFY mediaArtChanged)

public:
	explicit QMafwWatchletPlayer(QMafwWatchlet* watchlet);

	QString title() const;
	QString album() const;
	QString artist() const;
	QUrl mediaArt() const;

signals:
	void titleChanged();
	void albumChanged();
	void artistChanged();
	void mediaArtChanged();

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;
	QString _rendererArt;
	QUrl _mediaArt;

	void setRenderer(MafwRenderer*);
	void reconnect();

	static QString stripAlbumArtComponent(const QString& component);
	QString mediaArtPath() const;
	void updateMediaArt();

private slots:
	void handleMediaChange();
	void handleChangedMetadata(const QString& s, const QList<QVariant>& l);
	void handleChangedState(MafwRenderer::State state);
	void handleMediaInfo(const MafwMediaInfo& info);
	void handleStatusResults(const QString& playlistId, uint playbackIndex, int playbackState);
	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