24 Q_SLOT
void __propertyChanged__(
const QDBusMessage& msg)
26 QList<QVariant> arguments = msg.arguments();
27 if (3 != arguments.count())
29 QString interfaceName = msg.arguments().at(0).toString();
30 if (interfaceName !=
"org.mpris.MediaPlayer2.Player")
32 QVariantMap changedProps = qdbus_cast<QVariantMap>(arguments.at(1).value<QDBusArgument>());
33 Q_FOREACH(
const QString &prop, changedProps.keys()) {
34 const QMetaObject* self = metaObject();
35 for (
int i=self->propertyOffset(); i < self->propertyCount(); ++i) {
36 QMetaProperty p = self->property(i);
37#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
38 QGenericArgument value(QMetaType::typeName(p.type()),
const_cast<void*
>(changedProps[prop].constData()));
40 QGenericArgument value{p.metaType().name(),
const_cast<void*
>(changedProps[prop].constData())};
42 if (p.name() == prop) {
43 Q_EMIT p.notifySignal().invoke(
this, value);
49 static inline const char *staticInterfaceName()
50 {
return "org.mpris.MediaPlayer2.Player"; }
53 DBusMPRIS(
const QString &service,
const QString &path,
const QDBusConnection &connection, QObject *parent = 0);
57 Q_PROPERTY(
bool CanControl READ canControl NOTIFY CanControlChanged)
58 inline bool canControl()
const
59 {
return qvariant_cast< bool >(property(
"CanControl")); }
61 Q_PROPERTY(
bool CanShowInUI READ canShowInUI NOTIFY CanShowInUIChanged)
62 inline bool canShowInUI()
const
64 QVariant showInUI = property(
"CanShowInUI");
66 return showInUI.isValid() ? showInUI.toBool() :
true;
69 Q_PROPERTY(
bool CanGoNext READ canGoNext NOTIFY CanGoNextChanged)
70 inline bool canGoNext()
const
71 {
return qvariant_cast< bool >(property(
"CanGoNext")); }
73 Q_PROPERTY(
bool CanGoPrevious READ canGoPrevious NOTIFY CanGoPreviousChanged)
74 inline bool canGoPrevious()
const
75 {
return qvariant_cast< bool >(property(
"CanGoPrevious")); }
77 Q_PROPERTY(
bool CanPause READ canPause NOTIFY CanPauseChanged)
78 inline bool canPause()
const
79 {
return qvariant_cast< bool >(property(
"CanPause")); }
81 Q_PROPERTY(
bool CanPlay READ canPlay NOTIFY CanPlayChanged)
82 inline bool canPlay()
const
83 {
return qvariant_cast< bool >(property(
"CanPlay")); }
85 Q_PROPERTY(
bool CanSeek READ canSeek NOTIFY CanSeekChanged)
86 inline bool canSeek()
const
87 {
return qvariant_cast< bool >(property(
"CanSeek")); }
89 Q_PROPERTY(QString LoopStatus READ loopStatus WRITE setLoopStatus NOTIFY LoopStatusChanged)
90 inline QString loopStatus()
const
91 {
return qvariant_cast< QString >(property(
"LoopStatus")); }
92 inline void setLoopStatus(
const QString &value)
93 { setProperty(
"LoopStatus", QVariant::fromValue(value)); }
95 Q_PROPERTY(
double MaximumRate READ maximumRate NOTIFY MaximumRateChanged)
96 inline double maximumRate()
const
97 {
return qvariant_cast< double >(property(
"MaximumRate")); }
99 Q_PROPERTY(QVariantMap Metadata READ metadata NOTIFY MetadataChanged)
100 inline QVariantMap metadata()
const
101 {
return qvariant_cast< QVariantMap >(property(
"Metadata")); }
103 Q_PROPERTY(
double MinimumRate READ minimumRate NOTIFY MinimumRateChanged)
104 inline double minimumRate()
const
105 {
return qvariant_cast< double >(property(
"MinimumRate")); }
107 Q_PROPERTY(QString PlaybackStatus READ playbackStatus NOTIFY PlaybackStatusChanged)
108 inline QString playbackStatus()
const
109 {
return qvariant_cast< QString >(property(
"PlaybackStatus")); }
111 Q_PROPERTY(qlonglong Position READ position NOTIFY PositionChanged)
112 inline qlonglong position()
const
113 {
return qvariant_cast< qlonglong >(property(
"Position")); }
115 Q_PROPERTY(
double Rate READ rate WRITE setRate NOTIFY RateChanged)
116 inline double rate()
const
117 {
return qvariant_cast< double >(property(
"Rate")); }
118 inline void setRate(
double value)
119 { setProperty(
"Rate", QVariant::fromValue(value)); }
121 Q_PROPERTY(
bool Shuffle READ shuffle WRITE setShuffle NOTIFY ShuffleChanged)
122 inline bool shuffle()
const
123 {
return qvariant_cast< bool >(property(
"Shuffle")); }
124 inline void setShuffle(
bool value)
125 { setProperty(
"Shuffle", QVariant::fromValue(value)); }
127 Q_PROPERTY(
double Volume READ volume WRITE setVolume NOTIFY VolumeChanged)
128 inline double volume()
const
129 {
return qvariant_cast< double >(property(
"Volume")); }
130 inline void setVolume(
double value)
131 { setProperty(
"Volume", QVariant::fromValue(value)); }
134 inline QDBusPendingReply<> Next()
136 QList<QVariant> argumentList;
137 return asyncCallWithArgumentList(QStringLiteral(
"Next"), argumentList);
140 inline QDBusPendingReply<> OpenUri(
const QString &Uri)
142 QList<QVariant> argumentList;
143 argumentList << QVariant::fromValue(Uri);
144 return asyncCallWithArgumentList(QStringLiteral(
"OpenUri"), argumentList);
147 inline QDBusPendingReply<> Pause()
149 QList<QVariant> argumentList;
150 return asyncCallWithArgumentList(QStringLiteral(
"Pause"), argumentList);
153 inline QDBusPendingReply<> Play()
155 QList<QVariant> argumentList;
156 return asyncCallWithArgumentList(QStringLiteral(
"Play"), argumentList);
159 inline QDBusPendingReply<> PlayPause()
161 QList<QVariant> argumentList;
162 return asyncCallWithArgumentList(QStringLiteral(
"PlayPause"), argumentList);
165 inline QDBusPendingReply<> Previous()
167 QList<QVariant> argumentList;
168 return asyncCallWithArgumentList(QStringLiteral(
"Previous"), argumentList);
171 inline QDBusPendingReply<> Seek(qlonglong Offset)
173 QList<QVariant> argumentList;
174 argumentList << QVariant::fromValue(Offset);
175 return asyncCallWithArgumentList(QStringLiteral(
"Seek"), argumentList);
178 inline QDBusPendingReply<> SetPosition(
const QDBusObjectPath &TrackId, qlonglong Position)
180 QList<QVariant> argumentList;
181 argumentList << QVariant::fromValue(TrackId) << QVariant::fromValue(Position);
182 return asyncCallWithArgumentList(QStringLiteral(
"SetPosition"), argumentList);
185 inline QDBusPendingReply<> Stop()
187 QList<QVariant> argumentList;
188 return asyncCallWithArgumentList(QStringLiteral(
"Stop"), argumentList);
192 void Seeked(qlonglong Position);
194void CanControlChanged(
bool value);
195void CanShowInUIChanged(
bool value);
196void CanGoNextChanged(
bool value);
197void CanGoPreviousChanged(
bool value);
198void CanPauseChanged(
bool value);
199void CanPlayChanged(
bool value);
200void CanSeekChanged(
bool value);
201void LoopStatusChanged(
const QString & value);
202void MaximumRateChanged(
double value);
203void MetadataChanged(
const QVariantMap & value);
204void MinimumRateChanged(
double value);
205void PlaybackStatusChanged(
const QString & value);
206void PositionChanged(qlonglong value);
207void RateChanged(
double value);
208void ShuffleChanged(
bool value);
209void VolumeChanged(
double value);