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