Sayonara Player
DBusMPRIS.h
1 /* DBusMPRIS.h */
2 
3 /* Copyright (C) 2011-2019 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 
105  Q_PROPERTY(bool Shuffle READ Shuffle WRITE SetShuffle)
106  bool Shuffle();
107  void SetShuffle(bool shuffle);
108 
109 
110  Q_PROPERTY(QVariantMap Metadata READ Metadata)
111  QVariantMap Metadata();
112 
113 
114  Q_PROPERTY(double Volume READ Volume WRITE SetVolume)
115  double Volume();
116  void SetVolume(double volume);
117 
118 
119  Q_PROPERTY(qlonglong Position READ Position)
120  qlonglong Position();
121  void SetPosition(const QDBusObjectPath& track_id, qlonglong position);
122 
123 
124  Q_PROPERTY(double MinimumRate READ MinimumRate)
125  double MinimumRate();
126 
127 
128  Q_PROPERTY(double MaximumRate READ MaximumRate)
129  double MaximumRate();
130 
131 
132  Q_PROPERTY(bool CanGoNext READ CanGoNext)
133  bool CanGoNext();
134 
135 
136  Q_PROPERTY(bool CanGoPrevious READ CanGoPrevious)
137  bool CanGoPrevious();
138 
139 
140  Q_PROPERTY(bool CanPlay READ CanPlay)
141  bool CanPlay();
142 
143 
144  Q_PROPERTY(bool CanPause READ CanPause)
145  bool CanPause();
146 
147 
148  Q_PROPERTY(bool CanSeek READ CanSeek)
149  bool CanSeek();
150 
151 
152  Q_PROPERTY(bool CanControl READ CanControl)
153  bool CanControl();
154 
155 
156  void Next();
157  void Previous();
158  void Pause();
159  void PlayPause();
160  void Stop();
161  void Play();
162  void Seek(qlonglong offset);
163 
164  void OpenUri(const QString& uri);
165 
166 
167  public slots:
168 
169  void position_changed(MilliSeconds pos_ms);
170  void volume_changed(int volume);
171  void track_idx_changed(int idx);
172  void track_changed(const MetaData& md);
173  void playstate_changed(PlayState state);
174 
175  signals:
176  void Seeked(qlonglong position);
177  void sig_raise();
178 };
179 } // end namespace DBusMPRIS
180 
181 #endif // DBUS_MPRIS_H
PlayState
PlayState
The PlayState enum.
Definition: PlayState.h:28
DBusMPRIS::MediaPlayer2
Definition: DBusMPRIS.h:41
MetaData
The MetaData class.
Definition: MetaData.h:44
DBusAdaptor
Definition: DBusAdaptor.h:31