1 | /* |
2 | * BluezQt - Asynchronous Bluez wrapper library |
3 | * |
4 | * SPDX-FileCopyrightText: 2015 David Rosca <nowrep@gmail.com> |
5 | * |
6 | * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL |
7 | */ |
8 | |
9 | #ifndef DECLARATIVEMEDIAPLAYER_H |
10 | #define DECLARATIVEMEDIAPLAYER_H |
11 | |
12 | #include <QJsonObject> |
13 | #include <qqmlregistration.h> |
14 | |
15 | #include "mediaplayer.h" |
16 | #include "pendingcall.h" |
17 | |
18 | class DeclarativeMediaPlayer : public QObject |
19 | { |
20 | Q_OBJECT |
21 | QML_NAMED_ELEMENT(MediaPlayer) |
22 | QML_UNCREATABLE("MediaPlayer cannot be created" ) |
23 | Q_PROPERTY(QString name READ name NOTIFY nameChanged) |
24 | Q_PROPERTY(BluezQt::MediaPlayer::Equalizer equalizer READ equalizer WRITE setEqualizer NOTIFY equalizerChanged) |
25 | Q_PROPERTY(BluezQt::MediaPlayer::Repeat repeat READ repeat WRITE setRepeat NOTIFY repeatChanged) |
26 | Q_PROPERTY(BluezQt::MediaPlayer::Shuffle shuffle READ shuffle WRITE setShuffle NOTIFY shuffleChanged) |
27 | Q_PROPERTY(BluezQt::MediaPlayer::Status status READ status NOTIFY statusChanged) |
28 | Q_PROPERTY(QJsonObject track READ track NOTIFY trackChanged) |
29 | Q_PROPERTY(quint32 position READ position NOTIFY positionChanged) |
30 | |
31 | public: |
32 | explicit DeclarativeMediaPlayer(BluezQt::MediaPlayerPtr mediaPlayer, QObject *parent = nullptr); |
33 | |
34 | QString name() const; |
35 | |
36 | BluezQt::MediaPlayer::Equalizer equalizer() const; |
37 | void setEqualizer(BluezQt::MediaPlayer::Equalizer equalizer); |
38 | |
39 | BluezQt::MediaPlayer::Repeat repeat() const; |
40 | void setRepeat(BluezQt::MediaPlayer::Repeat repeat); |
41 | |
42 | BluezQt::MediaPlayer::Shuffle shuffle() const; |
43 | void setShuffle(BluezQt::MediaPlayer::Shuffle shuffle); |
44 | |
45 | BluezQt::MediaPlayer::Status status() const; |
46 | |
47 | QJsonObject track() const; |
48 | |
49 | quint32 position() const; |
50 | |
51 | public Q_SLOTS: |
52 | BluezQt::PendingCall *play(); |
53 | BluezQt::PendingCall *pause(); |
54 | BluezQt::PendingCall *stop(); |
55 | BluezQt::PendingCall *next(); |
56 | BluezQt::PendingCall *previous(); |
57 | BluezQt::PendingCall *fastForward(); |
58 | BluezQt::PendingCall *rewind(); |
59 | |
60 | Q_SIGNALS: |
61 | void nameChanged(const QString &name); |
62 | void equalizerChanged(BluezQt::MediaPlayer::Equalizer equalizer); |
63 | void repeatChanged(BluezQt::MediaPlayer::Repeat repeat); |
64 | void shuffleChanged(BluezQt::MediaPlayer::Shuffle shuffle); |
65 | void statusChanged(BluezQt::MediaPlayer::Status status); |
66 | void trackChanged(const QJsonObject &track); |
67 | void positionChanged(quint32 position); |
68 | |
69 | private: |
70 | void updateTrack(); |
71 | |
72 | BluezQt::MediaPlayerPtr m_mediaPlayer; |
73 | QJsonObject m_track; |
74 | }; |
75 | |
76 | #endif // DECLARATIVEMEDIAPLAYER_H |
77 | |