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 BLUEZQT_MEDIAPLAYER_H
10#define BLUEZQT_MEDIAPLAYER_H
11
12#include <QObject>
13
14#include "bluezqt_export.h"
15#include "mediaplayertrack.h"
16#include "types.h"
17
18#include <memory>
19
20namespace BluezQt
21{
22class PendingCall;
23
24/*!
25 * \inmodule BluezQt
26 * \class BluezQt::MediaPlayer
27 * \inheaderfile BluezQt/MediaPlayer
28 * \brief Media player.
29 *
30 * This class represents a media player interface.
31 */
32class BLUEZQT_EXPORT MediaPlayer : public QObject
33{
34 Q_OBJECT
35 /*! \property BluezQt::MediaPlayer::name */
36 Q_PROPERTY(QString name READ name NOTIFY nameChanged)
37 /*! \property BluezQt::MediaPlayer::equalizer */
38 Q_PROPERTY(Equalizer equalizer READ equalizer WRITE setEqualizer NOTIFY equalizerChanged)
39 /*! \property BluezQt::MediaPlayer::repeat */
40 Q_PROPERTY(Repeat repeat READ repeat WRITE setRepeat NOTIFY repeatChanged)
41 /*! \property BluezQt::MediaPlayer::shuffle */
42 Q_PROPERTY(Shuffle shuffle READ shuffle WRITE setShuffle NOTIFY shuffleChanged)
43 /*! \property BluezQt::MediaPlayer::status */
44 Q_PROPERTY(Status status READ status NOTIFY statusChanged)
45 /*! \property BluezQt::MediaPlayer::track */
46 Q_PROPERTY(MediaPlayerTrack track READ track NOTIFY trackChanged)
47 /*! \property BluezQt::MediaPlayer::position */
48 Q_PROPERTY(quint32 position READ position NOTIFY positionChanged)
49
50public:
51 /*!
52 * \value EqualizerOn
53 * \value EqualizerOff
54 */
55 enum Equalizer {
56 EqualizerOn,
57 EqualizerOff,
58 };
59 Q_ENUM(Equalizer)
60
61 /*!
62 * \value RepeatOff
63 * \value RepeatSingleTrack
64 * \value RepeatAllTracks
65 * \value RepeatGroup
66 */
67 enum Repeat {
68 RepeatOff,
69 RepeatSingleTrack,
70 RepeatAllTracks,
71 RepeatGroup,
72 };
73 Q_ENUM(Repeat)
74
75 /*!
76 * \value ShuffleOff
77 * \value ShuffleAllTracks
78 * \value ShuffleGroup
79 */
80 enum Shuffle {
81 ShuffleOff,
82 ShuffleAllTracks,
83 ShuffleGroup,
84 };
85 Q_ENUM(Shuffle)
86
87 /*!
88 * \value Playing
89 * \value Stopped
90 * \value Paused
91 * \value ForwardSeek
92 * \value ReverseSeek
93 * \value Error
94 */
95 enum Status {
96 Playing,
97 Stopped,
98 Paused,
99 ForwardSeek,
100 ReverseSeek,
101 Error,
102 };
103 Q_ENUM(Status)
104
105 ~MediaPlayer() override;
106
107 /*!
108 * Returns a shared pointer from this.
109 */
110 MediaPlayerPtr toSharedPtr() const;
111
112 /*!
113 * Returns the name of the player.
114 */
115 QString name() const;
116
117 /*!
118 * Returns the equalizer state of the player.
119 */
120 Equalizer equalizer() const;
121
122 /*!
123 * Sets the \a equalizer state of the player.
124 *
125 * Returns void pending call.
126 */
127 PendingCall *setEqualizer(Equalizer equalizer);
128
129 /*!
130 * Returns the repeat state of the player.
131 */
132 Repeat repeat() const;
133
134 /*!
135 * Sets the \a repeat state of the player.
136 *
137 * Returns void pending call.
138 */
139 PendingCall *setRepeat(Repeat repeat);
140
141 /*!
142 * Returns the shuffle state of the player.
143 */
144 Shuffle shuffle() const;
145
146 /*!
147 * Sets the \a shuffle state of the player.
148 *
149 * Returns void pending call.
150 */
151 PendingCall *setShuffle(Shuffle shuffle);
152
153 /*!
154 * Returns the status of the player.
155 */
156 Status status() const;
157
158 /*!
159 * Returns the current track.
160 */
161 MediaPlayerTrack track() const;
162
163 /*!
164 * Returns the playback position in milliseconds.
165 */
166 quint32 position() const;
167
168public Q_SLOTS:
169 /*!
170 * Resumes playback.
171 *
172 * Possible errors:
173 *
174 * \list
175 * \li PendingCall::NotSupported
176 * \li PendingCall::Failed
177 * \endlist
178 *
179 * Returns void pending call.
180 */
181 PendingCall *play();
182
183 /*!
184 * Pauses playback.
185 *
186 * Possible errors:
187 *
188 * \list
189 * \li PendingCall::NotSupported
190 * \li PendingCall::Failed
191 * \endlist
192 *
193 * Returns void pending call.
194 */
195 PendingCall *pause();
196
197 /*!
198 * Stops playback.
199 *
200 * Possible errors:
201 *
202 * \list
203 * \li PendingCall::NotSupported
204 * \li PendingCall::Failed
205 * \endlist
206 *
207 * Returns void pending call.
208 */
209 PendingCall *stop();
210
211 /*!
212 * Switches to the next track.
213 *
214 * Possible errors:
215 *
216 * \list
217 * \li PendingCall::NotSupported
218 * \li PendingCall::Failed
219 * \endlist
220 *
221 * Returns void pending call.
222 */
223 PendingCall *next();
224
225 /*!
226 * Switch to previous track.
227 *
228 * Possible errors:
229 *
230 * \list
231 * \li PendingCall::NotSupported
232 * \li PendingCall::Failed
233 * \endlist
234 *
235 * Returns void pending call.
236 */
237 PendingCall *previous();
238
239 /*!
240 * Fast forwards playback.
241 *
242 * Possible errors:
243 *
244 * \list
245 * \li PendingCall::NotSupported
246 * \li PendingCall::Failed
247 * \endlist
248 *
249 * Returns void pending call.
250 */
251 PendingCall *fastForward();
252
253 /*!
254 * Rewinds playback.
255 *
256 * Possible errors:
257 *
258 * \list
259 * \li PendingCall::NotSupported
260 * \li PendingCall::Failed
261 * \endlist
262 *
263 * Returns void pending call.
264 */
265 PendingCall *rewind();
266
267Q_SIGNALS:
268 /*!
269 * Indicates that the player's \a name has changed.
270 */
271 void nameChanged(const QString &name);
272
273 /*!
274 * Indicates that the player's \a equalizer state has changed.
275 */
276 void equalizerChanged(Equalizer equalizer);
277
278 /*!
279 * Indicates that the player's \a repeat state has changed.
280 */
281 void repeatChanged(Repeat repeat);
282
283 /*!
284 * Indicates that the player's \a shuffle state has changed.
285 */
286 void shuffleChanged(Shuffle shuffle);
287
288 /*!
289 * Indicates that the player's \a status has changed.
290 */
291 void statusChanged(Status status);
292
293 /*!
294 * Indicates that the player's current \a track has changed.
295 */
296 void trackChanged(MediaPlayerTrack track);
297
298 /*!
299 * Indicates that the player's playback \a position has changed.
300 */
301 void positionChanged(quint32 position);
302
303private:
304 BLUEZQT_NO_EXPORT explicit MediaPlayer(const QString &path, const QVariantMap &properties);
305
306 std::unique_ptr<class MediaPlayerPrivate> const d;
307
308 friend class MediaPlayerPrivate;
309 friend class DevicePrivate;
310};
311
312} // namespace BluezQt
313
314#endif // BLUEZQT_MEDIAPLAYER_H
315

source code of bluez-qt/src/mediaplayer.h