mirror of
https://github.com/kavishdevar/librepods.git
synced 2026-04-28 17:17:54 +00:00
[Linux] Use DBus for following media playback change
This commit is contained in:
committed by
Tim Gromeyer
parent
5754dbfb16
commit
38d6f8ceae
61
linux/media/mediacontroller.h
Normal file
61
linux/media/mediacontroller.h
Normal file
@@ -0,0 +1,61 @@
|
||||
#ifndef MEDIACONTROLLER_H
|
||||
#define MEDIACONTROLLER_H
|
||||
|
||||
#include <QDBusInterface>
|
||||
#include <QObject>
|
||||
|
||||
class QProcess;
|
||||
class EarDetection;
|
||||
class PlayerStatusWatcher;
|
||||
|
||||
class MediaController : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
enum MediaState
|
||||
{
|
||||
Playing,
|
||||
Paused,
|
||||
Stopped
|
||||
};
|
||||
Q_ENUM(MediaState)
|
||||
enum EarDetectionBehavior
|
||||
{
|
||||
PauseWhenOneRemoved,
|
||||
PauseWhenBothRemoved,
|
||||
Disabled
|
||||
};
|
||||
Q_ENUM(EarDetectionBehavior)
|
||||
|
||||
explicit MediaController(QObject *parent = nullptr);
|
||||
~MediaController();
|
||||
|
||||
void handleEarDetection(EarDetection*);
|
||||
void followMediaChanges();
|
||||
bool isActiveOutputDeviceAirPods();
|
||||
void handleConversationalAwareness(const QByteArray &data);
|
||||
void activateA2dpProfile();
|
||||
void removeAudioOutputDevice();
|
||||
void setConnectedDeviceMacAddress(const QString &macAddress);
|
||||
|
||||
void setEarDetectionBehavior(EarDetectionBehavior behavior);
|
||||
inline EarDetectionBehavior getEarDetectionBehavior() const { return earDetectionBehavior; }
|
||||
|
||||
void pause();
|
||||
|
||||
Q_SIGNALS:
|
||||
void mediaStateChanged(MediaState state);
|
||||
|
||||
private:
|
||||
MediaState mediaStateFromPlayerctlOutput(const QString &output);
|
||||
QString getAudioDeviceName();
|
||||
|
||||
bool wasPausedByApp = false;
|
||||
int initialVolume = -1;
|
||||
QString connectedDeviceMacAddress;
|
||||
EarDetectionBehavior earDetectionBehavior = PauseWhenOneRemoved;
|
||||
QString m_deviceOutputName;
|
||||
PlayerStatusWatcher *playerStatusWatcher = nullptr;
|
||||
};
|
||||
|
||||
#endif // MEDIACONTROLLER_H
|
||||
Reference in New Issue
Block a user