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