Mpris2: Add new property to read/write the rating
This commit is contained in:
parent
0bc94b90d7
commit
f5a55abf58
@ -212,6 +212,7 @@ void Mpris2::EmitNotification(const QString &name) {
|
||||
else if (name == "LoopStatus") value = LoopStatus();
|
||||
else if (name == "Shuffle") value = Shuffle();
|
||||
else if (name == "Metadata") value = Metadata();
|
||||
else if (name == "Rating") value = Rating();
|
||||
else if (name == "Volume") value = Volume();
|
||||
else if (name == "Position") value = Position();
|
||||
else if (name == "CanPlay") value = CanPlay();
|
||||
@ -369,6 +370,22 @@ void Mpris2::SetShuffle(bool enable) {
|
||||
|
||||
QVariantMap Mpris2::Metadata() const { return last_metadata_; }
|
||||
|
||||
double Mpris2::Rating() const {
|
||||
float rating = app_->playlist_manager()->active()->current_item_metadata().rating();
|
||||
return (rating <= 0) ? 0 : rating;
|
||||
}
|
||||
|
||||
void Mpris2::SetRating(double rating) {
|
||||
if (rating > 1.0) {
|
||||
rating = 1.0;
|
||||
}
|
||||
else if (rating <= 0.0) {
|
||||
rating = -1.0;
|
||||
}
|
||||
|
||||
app_->playlist_manager()->RateCurrentSong(rating);
|
||||
}
|
||||
|
||||
QString Mpris2::current_track_id() const {
|
||||
return QString("/org/strawberrymusicplayer/strawberry/Track/%1").arg(QString::number(app_->playlist_manager()->active()->current_row()));
|
||||
}
|
||||
|
@ -117,6 +117,9 @@ class Mpris2 : public QObject {
|
||||
Q_PROPERTY(QStringList Orderings READ Orderings)
|
||||
Q_PROPERTY(MaybePlaylist ActivePlaylist READ ActivePlaylist)
|
||||
|
||||
// strawberry specific additional property to extend MPRIS Player interface
|
||||
Q_PROPERTY(double Rating READ Rating WRITE SetRating)
|
||||
|
||||
// Root Properties
|
||||
bool CanQuit() const;
|
||||
bool CanRaise() const;
|
||||
@ -144,6 +147,8 @@ class Mpris2 : public QObject {
|
||||
bool Shuffle() const;
|
||||
void SetShuffle(bool enable);
|
||||
QVariantMap Metadata() const;
|
||||
double Rating() const;
|
||||
void SetRating(double rating);
|
||||
double Volume() const;
|
||||
void SetVolume(const double volume);
|
||||
qint64 Position() const;
|
||||
|
@ -29,6 +29,7 @@
|
||||
<property name='Metadata' type='a{sv}' access='read'>
|
||||
<annotation name="org.qtproject.QtDBus.QtTypeName" value="QVariantMap"/>
|
||||
</property>
|
||||
<property name='Rating' type='d' access='readwrite'/>
|
||||
<property name='Volume' type='d' access='readwrite'/>
|
||||
<property name='Position' type='x' access='read'/>
|
||||
<property name='MinimumRate' type='d' access='read'/>
|
||||
|
Loading…
x
Reference in New Issue
Block a user