summaryrefslogtreecommitdiff
path: root/qmafwwatchlet/qmafwwatchletplayer.h
blob: 4a587a6fca3554d066a4a81bf621d750e729a054 (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
#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 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