forked from quickshell/quickshell
feat: mpris
This commit is contained in:
parent
73cfeba61b
commit
3b6d1c3bd8
11 changed files with 749 additions and 1 deletions
67
src/services/mpris/player.hpp
Normal file
67
src/services/mpris/player.hpp
Normal file
|
@ -0,0 +1,67 @@
|
|||
#pragma once
|
||||
|
||||
#include <qdbusextratypes.h>
|
||||
#include <qdbuspendingcall.h>
|
||||
#include <qloggingcategory.h>
|
||||
#include <qobject.h>
|
||||
#include <qtypes.h>
|
||||
|
||||
#include "../../dbus/properties.hpp"
|
||||
#include "dbus_player.h"
|
||||
|
||||
Q_DECLARE_LOGGING_CATEGORY(logMprisPlayer);
|
||||
|
||||
namespace qs::service::mp {
|
||||
|
||||
class MprisPlayer;
|
||||
|
||||
class MprisPlayer: public QObject {
|
||||
Q_OBJECT;
|
||||
|
||||
public:
|
||||
explicit MprisPlayer(const QString& address, QObject* parent = nullptr);
|
||||
QString watcherId; // TODO: maybe can be private CHECK
|
||||
|
||||
void setPosition(QDBusObjectPath trackId, qlonglong position);
|
||||
void next();
|
||||
void previous();
|
||||
void pause();
|
||||
void playPause();
|
||||
void stop();
|
||||
void play();
|
||||
|
||||
[[nodiscard]] bool isValid() const;
|
||||
[[nodiscard]] bool isReady() const;
|
||||
|
||||
// clang-format off
|
||||
dbus::DBusPropertyGroup properties;
|
||||
dbus::DBusProperty<bool> canControl {this->properties, "CanControl" };
|
||||
dbus::DBusProperty<bool> canGoNext {this->properties, "CanGoNext" };
|
||||
dbus::DBusProperty<bool> canGoPrevious {this->properties, "CanGoPrevious" };
|
||||
dbus::DBusProperty<bool> canPlay {this->properties, "CanPlay" };
|
||||
dbus::DBusProperty<bool> canPause {this->properties, "CanPause" };
|
||||
dbus::DBusProperty<QVariantMap> metadata {this->properties, "Metadata"};
|
||||
dbus::DBusProperty<QString> playbackStatus {this->properties, "PlaybackStatus" };
|
||||
dbus::DBusProperty<qlonglong> position {this->properties, "Position" };
|
||||
dbus::DBusProperty<double> minimumRate {this->properties, "MinimumRate" };
|
||||
dbus::DBusProperty<double> maximumRate {this->properties, "MaximumRate" };
|
||||
|
||||
dbus::DBusProperty<QString> loopStatus {this->properties, "LoopStatus" };
|
||||
dbus::DBusProperty<double> rate {this->properties, "Rate" };
|
||||
dbus::DBusProperty<bool> shuffle {this->properties, "Shuffle" };
|
||||
dbus::DBusProperty<double> volume {this->properties, "Volume" };
|
||||
// clang-format on
|
||||
|
||||
signals:
|
||||
void ready();
|
||||
|
||||
private slots:
|
||||
void onGetAllFinished();
|
||||
void updatePlayer();
|
||||
|
||||
private:
|
||||
DBusMprisPlayer* player = nullptr;
|
||||
bool mReady = false;
|
||||
};
|
||||
|
||||
} // namespace qs::service::mp
|
Loading…
Add table
Add a link
Reference in a new issue