Sayonara Player
Loading...
Searching...
No Matches
DBusMPRIS.h
1/* DBusMPRIS.h */
2
3/* Copyright (C) 2011-2024 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;
37namespace Playlist
38{
39 class Accessor;
40}
41
42namespace Dbus::Mpris
43{
45 public Adapator
46 {
47 Q_OBJECT
48 PIMPL(MediaPlayer2)
49
50 signals:
51 void Seeked(qlonglong position);
52
53 public:
54 MediaPlayer2(QMainWindow* player, PlayManager* playManager, Playlist::Accessor* playlistAccessor);
55 ~MediaPlayer2() override;
56
57 Q_PROPERTY(bool CanQuit READ CanQuit CONSTANT)
58 [[nodiscard]] bool CanQuit() const;
59
60 Q_PROPERTY(bool CanRaise READ CanRaise CONSTANT)
61 bool CanRaise();
62
63 Q_PROPERTY(bool HasTrackList READ HasTrackList)
64 bool HasTrackList();
65
66 Q_PROPERTY(QString Identity READ Identity CONSTANT)
67 QString Identity();
68
69 Q_PROPERTY(QString DesktopEntry READ DesktopEntry CONSTANT)
70 QString DesktopEntry();
71
72 Q_PROPERTY(QStringList SupportedUriSchemes READ SupportedUriSchemes CONSTANT)
73 QStringList SupportedUriSchemes();
74
75 Q_PROPERTY(QStringList SupportedMimeTypes READ SupportedMimeTypes CONSTANT)
76 QStringList SupportedMimeTypes();
77
78 Q_PROPERTY(bool CanSetFullscreen READ CanSetFullscreen)
79 bool CanSetFullscreen();
80
81 Q_PROPERTY(bool Fullscreen READ Fullscreen WRITE SetFullscreen)
82 bool Fullscreen();
83 void SetFullscreen(bool b);
84
85 [[maybe_unused]] void Raise();
86 [[maybe_unused]] void Quit();
87
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 [[maybe_unused]] void IncreaseVolume();
113 [[maybe_unused]] void DecreaseVolume();
114
115 Q_PROPERTY(qlonglong Position READ Position)
116 qlonglong Position();
117 [[maybe_unused]] 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 [[maybe_unused]] void Previous();
145 [[maybe_unused]] void Pause();
146 [[maybe_unused]] void PlayPause();
147 void Stop();
148 void Play();
149 [[maybe_unused]] void Seek(qlonglong offset);
150 [[maybe_unused]] void OpenUri(const QString& uri);
151
152 public slots: // NOLINT(readability-redundant-access-specifiers)
153 void positionChanged(MilliSeconds pos_ms);
154 void volumeChanged(int volume);
155 void trackIndexChanged(int idx);
156 void trackChanged(const MetaData& track);
157 void playstateChanged(PlayState state);
158
159 private: // NOLINT(readability-redundant-access-specifiers)
160 void init();
161 };
162} // end namespace Dbus::MPRIS
163
164#endif // DBUS_MPRIS_H
Definition DBusAdaptor.h:32
Definition DBusMPRIS.h:46
The MetaData class.
Definition MetaData.h:47
Definition PlayManager.h:34
Definition PlaylistInterface.h:43