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