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 "DBusAdaptor.h"
25
26#include "Utils/MetaData/MetaData.h"
27#include "Utils/Pimpl.h"
28
29#include <QObject>
30#include <QVariant>
31#include <QDBusObjectPath>
32
33using QStrRef = const QString&;
34
35class QMainWindow;
36class PlayManager;
38
39namespace DBusMPRIS
40{
41
43 public DBusAdaptor
44 {
45 Q_OBJECT
46 PIMPL(MediaPlayer2)
47
48 public:
49 explicit MediaPlayer2(QMainWindow* player, PlayManager* playManager, PlaylistAccessor* playlistAccessor,
50 QObject* parent = nullptr);
52
53 Q_PROPERTY(bool CanQuit READ CanQuit CONSTANT)
54 bool CanQuit() const;
55
56 Q_PROPERTY(bool CanRaise READ CanRaise CONSTANT)
57 bool CanRaise();
58
59 Q_PROPERTY(bool HasTrackList READ HasTrackList)
60 bool HasTrackList();
61
62 Q_PROPERTY(QString Identity READ Identity CONSTANT)
63 QString Identity();
64
65 Q_PROPERTY(QString DesktopEntry READ DesktopEntry CONSTANT)
66 QString DesktopEntry();
67
68 Q_PROPERTY(QStringList SupportedUriSchemes READ SupportedUriSchemes CONSTANT)
69 QStringList SupportedUriSchemes();
70
71 Q_PROPERTY(QStringList SupportedMimeTypes READ SupportedMimeTypes CONSTANT)
72 QStringList SupportedMimeTypes();
73
74 Q_PROPERTY(bool CanSetFullscreen READ CanSetFullscreen)
75 bool CanSetFullscreen();
76
77 Q_PROPERTY(bool Fullscreen READ Fullscreen WRITE SetFullscreen)
78 bool Fullscreen();
79 void SetFullscreen(bool b);
80
81 void Raise();
82 void Quit();
83
84 private:
85 void init();
86
87 public:
88 Q_PROPERTY(QString PlaybackStatus READ PlaybackStatus)
89 QString PlaybackStatus();
90
91 Q_PROPERTY(QString LoopStatus READ LoopStatus WRITE SetLoopStatus)
92 QString LoopStatus();
93 void SetLoopStatus(QString status);
94
95 Q_PROPERTY(double Rate READ Rate WRITE SetRate)
96 double Rate();
97 void SetRate(double rate);
98
99 Q_PROPERTY(int Rating READ Rating)
100 int Rating();
101
102 Q_PROPERTY(bool Shuffle READ Shuffle WRITE SetShuffle)
103 bool Shuffle();
104 void SetShuffle(bool shuffle);
105
106 Q_PROPERTY(QVariantMap Metadata READ Metadata)
107 QVariantMap Metadata();
108
109 Q_PROPERTY(double Volume READ Volume WRITE SetVolume)
110 double Volume();
111 void SetVolume(double volume);
112 void IncreaseVolume();
113 void DecreaseVolume();
114
115 Q_PROPERTY(qlonglong Position READ Position)
116 qlonglong Position();
117 void SetPosition(const QDBusObjectPath& trackId, qlonglong position);
118
119 Q_PROPERTY(double MinimumRate READ MinimumRate)
120 double MinimumRate();
121
122 Q_PROPERTY(double MaximumRate READ MaximumRate)
123 double MaximumRate();
124
125 Q_PROPERTY(bool CanGoNext READ CanGoNext)
126 bool CanGoNext();
127
128 Q_PROPERTY(bool CanGoPrevious READ CanGoPrevious)
129 bool CanGoPrevious();
130
131 Q_PROPERTY(bool CanPlay READ CanPlay)
132 bool CanPlay();
133
134 Q_PROPERTY(bool CanPause READ CanPause)
135 bool CanPause();
136
137 Q_PROPERTY(bool CanSeek READ CanSeek)
138 bool CanSeek();
139
140 Q_PROPERTY(bool CanControl READ CanControl)
141 bool CanControl();
142
143 void Next();
144 void Previous();
145 void Pause();
146 void PlayPause();
147 void Stop();
148 void Play();
149 void Seek(qlonglong offset);
150 void OpenUri(const QString& uri);
151
152 public slots:
153 void positionChanged(MilliSeconds pos_ms);
154 void volumeChanged(int volume);
155 void trackIndexChanged(int idx);
156 void trackChanged(const MetaData& md);
157 void playstateChanged(PlayState state);
158
159 signals:
160 void Seeked(qlonglong position);
161 void sigRaise();
162
163 private slots:
164 void trackMetadataChanged();
165
166 };
167} // end namespace DBusMPRIS
168
169#endif // DBUS_MPRIS_H
Definition: DBusAdaptor.h:33
Definition: DBusMPRIS.h:44
The MetaData class.
Definition: MetaData.h:47
Global handler for current playback state (Singleton)
Definition: PlayManager.h:36
Definition: PlaylistInterface.h:39