File indexing completed on 2024-12-01 12:29:50
0001 /* 0002 * BluezQt - Asynchronous BlueZ wrapper library 0003 * 0004 * SPDX-FileCopyrightText: 2015 David Rosca <nowrep@gmail.com> 0005 * 0006 * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0007 */ 0008 0009 #ifndef BLUEZQT_MEDIAPLAYER_H 0010 #define BLUEZQT_MEDIAPLAYER_H 0011 0012 #include <QObject> 0013 0014 #include "bluezqt_export.h" 0015 #include "mediaplayertrack.h" 0016 #include "types.h" 0017 0018 namespace BluezQt 0019 { 0020 class PendingCall; 0021 0022 /** 0023 * @class BluezQt::MediaPlayer mediaplayer.h <BluezQt/MediaPlayer> 0024 * 0025 * Media player. 0026 * 0027 * This class represents a media player interface. 0028 */ 0029 class BLUEZQT_EXPORT MediaPlayer : public QObject 0030 { 0031 Q_OBJECT 0032 Q_PROPERTY(QString name READ name NOTIFY nameChanged) 0033 Q_PROPERTY(Equalizer equalizer READ equalizer WRITE setEqualizer NOTIFY equalizerChanged) 0034 Q_PROPERTY(Repeat repeat READ repeat WRITE setRepeat NOTIFY repeatChanged) 0035 Q_PROPERTY(Shuffle shuffle READ shuffle WRITE setShuffle NOTIFY shuffleChanged) 0036 Q_PROPERTY(Status status READ status NOTIFY statusChanged) 0037 Q_PROPERTY(MediaPlayerTrack track READ track NOTIFY trackChanged) 0038 Q_PROPERTY(quint32 position READ position NOTIFY positionChanged) 0039 0040 public: 0041 /** Equalizer state. */ 0042 enum Equalizer { 0043 /** Equalizer on. */ 0044 EqualizerOn, 0045 /** Equalizer off. */ 0046 EqualizerOff, 0047 }; 0048 Q_ENUM(Equalizer) 0049 0050 /** Repeat state. */ 0051 enum Repeat { 0052 /** Repeat off. */ 0053 RepeatOff, 0054 /** Repeat single track. */ 0055 RepeatSingleTrack, 0056 /** Repeat all tracks. */ 0057 RepeatAllTracks, 0058 /** Repeat group. */ 0059 RepeatGroup, 0060 }; 0061 Q_ENUM(Repeat) 0062 0063 /** Shuffle state. */ 0064 enum Shuffle { 0065 /** Shuffle off. */ 0066 ShuffleOff, 0067 /** Shuffle all tracks. */ 0068 ShuffleAllTracks, 0069 /** Shuffle group. */ 0070 ShuffleGroup, 0071 }; 0072 Q_ENUM(Shuffle) 0073 0074 /** Player status. */ 0075 enum Status { 0076 /** Player is playing. */ 0077 Playing, 0078 /** Player is stopped. */ 0079 Stopped, 0080 /** Player is paused. */ 0081 Paused, 0082 /** Player is forward seeking. */ 0083 ForwardSeek, 0084 /** Player is reverse seeking. */ 0085 ReverseSeek, 0086 /** Error */ 0087 Error, 0088 }; 0089 Q_ENUM(Status) 0090 0091 /** 0092 * Destroys a MediaPlayer object. 0093 */ 0094 ~MediaPlayer() override; 0095 0096 /** 0097 * Returns a shared pointer from this. 0098 * 0099 * @return MediaPlayerPtr 0100 */ 0101 MediaPlayerPtr toSharedPtr() const; 0102 0103 /** 0104 * Returns the name of the player. 0105 * 0106 * @return name of player 0107 */ 0108 QString name() const; 0109 0110 /** 0111 * Returns the equalizer state of the player. 0112 * 0113 * @return equalizer state of player 0114 */ 0115 Equalizer equalizer() const; 0116 0117 /** 0118 * Sets the equalizer state of the player. 0119 * 0120 * @param equalizer equalizer state 0121 * @return void pending call 0122 */ 0123 PendingCall *setEqualizer(Equalizer equalizer); 0124 0125 /** 0126 * Returns the repeat state of the player. 0127 * 0128 * @return repeat state of player 0129 */ 0130 Repeat repeat() const; 0131 0132 /** 0133 * Sets the repeat state of the player. 0134 * 0135 * @param repeat repeat state 0136 * @return void pending call 0137 */ 0138 PendingCall *setRepeat(Repeat repeat); 0139 0140 /** 0141 * Returns the shuffle state of the player. 0142 * 0143 * @return shuffle state of player 0144 */ 0145 Shuffle shuffle() const; 0146 0147 /** 0148 * Sets the shuffle state of the player. 0149 * 0150 * @param shuffle shuffle state 0151 * @return void pending call 0152 */ 0153 PendingCall *setShuffle(Shuffle shuffle); 0154 0155 /** 0156 * Returns the status of the player. 0157 * 0158 * @return status of player 0159 */ 0160 Status status() const; 0161 0162 /** 0163 * Returns the current track. 0164 * 0165 * @return current track 0166 */ 0167 MediaPlayerTrack track() const; 0168 0169 /** 0170 * Returns the playback position in milliseconds. 0171 * 0172 * @return playback position 0173 */ 0174 quint32 position() const; 0175 0176 public Q_SLOTS: 0177 /** 0178 * Resumes playback. 0179 * 0180 * Possible errors: PendingCall::NotSupported, PendingCall::Failed 0181 * 0182 * @return void pending call 0183 */ 0184 PendingCall *play(); 0185 0186 /** 0187 * Pauses playback. 0188 * 0189 * Possible errors: PendingCall::NotSupported, PendingCall::Failed 0190 * 0191 * @return void pending call 0192 */ 0193 PendingCall *pause(); 0194 0195 /** 0196 * Stops playback. 0197 * 0198 * Possible errors: PendingCall::NotSupported, PendingCall::Failed 0199 * 0200 * @return void pending call 0201 */ 0202 PendingCall *stop(); 0203 0204 /** 0205 * Switch to next track. 0206 * 0207 * Possible errors: PendingCall::NotSupported, PendingCall::Failed 0208 * 0209 * @return void pending call 0210 */ 0211 PendingCall *next(); 0212 0213 /** 0214 * Switch to previous track. 0215 * 0216 * Possible errors: PendingCall::NotSupported, PendingCall::Failed 0217 * 0218 * @return void pending call 0219 */ 0220 PendingCall *previous(); 0221 0222 /** 0223 * Fast forwards playback. 0224 * 0225 * Possible errors: PendingCall::NotSupported, PendingCall::Failed 0226 * 0227 * @return void pending call 0228 */ 0229 PendingCall *fastForward(); 0230 0231 /** 0232 * Rewinds playback. 0233 * 0234 * Possible errors: PendingCall::NotSupported, PendingCall::Failed 0235 * 0236 * @return void pending call 0237 */ 0238 PendingCall *rewind(); 0239 0240 Q_SIGNALS: 0241 /** 0242 * Indicates that player's name have changed. 0243 */ 0244 void nameChanged(const QString &name); 0245 0246 /** 0247 * Indicates that player's equalizer state have changed. 0248 */ 0249 void equalizerChanged(Equalizer equalizer); 0250 0251 /** 0252 * Indicates that player's repeat state have changed. 0253 */ 0254 void repeatChanged(Repeat repeat); 0255 0256 /** 0257 * Indicates that player's shuffle state have changed. 0258 */ 0259 void shuffleChanged(Shuffle shuffle); 0260 0261 /** 0262 * Indicates that player's status have changed. 0263 */ 0264 void statusChanged(Status status); 0265 0266 /** 0267 * Indicates that player's current track have changed. 0268 */ 0269 void trackChanged(MediaPlayerTrack track); 0270 0271 /** 0272 * Indicates that player's playback position have changed. 0273 */ 0274 void positionChanged(quint32 position); 0275 0276 private: 0277 BLUEZQT_NO_EXPORT explicit MediaPlayer(const QString &path, const QVariantMap &properties); 0278 0279 class MediaPlayerPrivate *const d; 0280 0281 friend class MediaPlayerPrivate; 0282 friend class DevicePrivate; 0283 }; 0284 0285 } // namespace BluezQt 0286 0287 #endif // BLUEZQT_MEDIAPLAYER_H