Sayonara Player
DBusMPRIS.h
1 /* DBusMPRIS.h */
2 
3 /* Copyright (C) 2011-2020 Michael Lugmair (Lucio Carreras)
4  *
5  * This file is part of sayonara player
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11 
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16 
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 #ifndef DBUS_MPRIS_H
22 #define DBUS_MPRIS_H
23 
24 #include <QObject>
25 #include <QVariant>
26 #include <QDBusObjectPath>
27 
28 #include "DBusAdaptor.h"
29 #include "Components/PlayManager/PlayState.h"
30 
31 #include "Utils/MetaData/MetaData.h"
32 #include "Utils/Pimpl.h"
33 
34 using QStrRef=const QString&;
35 
36 class QMainWindow;
37 
38 namespace DBusMPRIS
39 {
40 
41 class MediaPlayer2 :
42  public DBusAdaptor
43 {
44  Q_OBJECT
45  PIMPL(MediaPlayer2)
46 
47  public:
48  explicit MediaPlayer2(QMainWindow* player, QObject* parent=nullptr);
49  ~MediaPlayer2();
50 
51  Q_PROPERTY(bool CanQuit READ CanQuit CONSTANT)
52  bool CanQuit() const;
53 
54  Q_PROPERTY(bool CanRaise READ CanRaise CONSTANT)
55  bool CanRaise();
56 
57  Q_PROPERTY(bool HasTrackList READ HasTrackList)
58  bool HasTrackList();
59 
60 
61  Q_PROPERTY(QString Identity READ Identity CONSTANT)
62  QString Identity();
63 
64  Q_PROPERTY(QString DesktopEntry READ DesktopEntry CONSTANT)
65  QString DesktopEntry();
66 
67  Q_PROPERTY(QStringList SupportedUriSchemes READ SupportedUriSchemes CONSTANT)
68  QStringList SupportedUriSchemes();
69 
70 
71  Q_PROPERTY(QStringList SupportedMimeTypes READ SupportedMimeTypes CONSTANT)
72  QStringList SupportedMimeTypes();
73 
74 
75  Q_PROPERTY(bool CanSetFullscreen READ CanSetFullscreen)
76  bool CanSetFullscreen();
77 
78  Q_PROPERTY(bool Fullscreen READ Fullscreen WRITE SetFullscreen)
79  bool Fullscreen();
80  void SetFullscreen(bool b);
81 
82  void Raise();
83  void Quit();
84 
85 
86  private:
87  void init();
88 
89 
90  public:
91  Q_PROPERTY(QString PlaybackStatus READ PlaybackStatus)
92  QString PlaybackStatus();
93 
94 
95  Q_PROPERTY(QString LoopStatus READ LoopStatus WRITE SetLoopStatus)
96  QString LoopStatus();
97  void SetLoopStatus(QString status);
98 
99 
100  Q_PROPERTY(double Rate READ Rate WRITE SetRate)
101  double Rate();
102  void SetRate(double rate);
103 
104  Q_PROPERTY(int Rating READ Rating)
105  int Rating();
106 
107 
108  Q_PROPERTY(bool Shuffle READ Shuffle WRITE SetShuffle)
109  bool Shuffle();
110  void SetShuffle(bool shuffle);
111 
112 
113  Q_PROPERTY(QVariantMap Metadata READ Metadata)
114  QVariantMap Metadata();
115 
116 
117  Q_PROPERTY(double Volume READ Volume WRITE SetVolume)
118  double Volume();
119  void SetVolume(double volume);
120  void IncreaseVolume();
121  void DecreaseVolume();
122 
123 
124  Q_PROPERTY(qlonglong Position READ Position)
125  qlonglong Position();
126  void SetPosition(const QDBusObjectPath& trackId, qlonglong position);
127 
128 
129  Q_PROPERTY(double MinimumRate READ MinimumRate)
130  double MinimumRate();
131 
132 
133  Q_PROPERTY(double MaximumRate READ MaximumRate)
134  double MaximumRate();
135 
136 
137  Q_PROPERTY(bool CanGoNext READ CanGoNext)
138  bool CanGoNext();
139 
140 
141  Q_PROPERTY(bool CanGoPrevious READ CanGoPrevious)
142  bool CanGoPrevious();
143 
144 
145  Q_PROPERTY(bool CanPlay READ CanPlay)
146  bool CanPlay();
147 
148 
149  Q_PROPERTY(bool CanPause READ CanPause)
150  bool CanPause();
151 
152 
153  Q_PROPERTY(bool CanSeek READ CanSeek)
154  bool CanSeek();
155 
156 
157  Q_PROPERTY(bool CanControl READ CanControl)
158  bool CanControl();
159 
160  void Next();
161  void Previous();
162  void Pause();
163  void PlayPause();
164  void Stop();
165  void Play();
166  void Seek(qlonglong offset);
167  void OpenUri(const QString& uri);
168 
169  public slots:
170  void positionChanged(MilliSeconds pos_ms);
171  void volumeChanged(int volume);
172  void trackIndexChanged(int idx);
173  void trackChanged(const MetaData& md);
174  void playstateChanged(PlayState state);
175 
176  signals:
177  void Seeked(qlonglong position);
178  void sigRaise();
179 
180  private slots:
181  void trackMetadataChanged();
182 
183 };
184 } // end namespace DBusMPRIS
185 
186 #endif // DBUS_MPRIS_H
PlayState
PlayState
The PlayState enum.
Definition: PlayState.h:29
DBusMPRIS::MediaPlayer2
Definition: DBusMPRIS.h:43
MetaData
The MetaData class.
Definition: MetaData.h:47
DBusAdaptor
Definition: DBusAdaptor.h:33