Skip to content

Commit 48ae249

Browse files
committed
[Linux] Don't use playerctl for current media state
1 parent aaf82c9 commit 48ae249

2 files changed

Lines changed: 3 additions & 6 deletions

File tree

linux/media/mediacontroller.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,7 @@ void MediaController::handleEarDetection(EarDetection *earDetection)
4444

4545
if (shouldPause && isActiveOutputDeviceAirPods())
4646
{
47-
QProcess process;
48-
process.start("playerctl", QStringList() << "status");
49-
process.waitForFinished();
50-
QString playbackStatus = process.readAllStandardOutput().trimmed();
51-
LOG_DEBUG("Playback status: " << playbackStatus);
52-
if (playbackStatus == "Playing")
47+
if (m_mediaState == Playing)
5348
{
5449
pause();
5550
}

linux/media/mediacontroller.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ class MediaController : public QObject
4343

4444
void play();
4545
void pause();
46+
MediaState getCurrentMediaState() const { return m_mediaState; };
4647

4748
Q_SIGNALS:
4849
void mediaStateChanged(MediaState state);
@@ -59,6 +60,7 @@ class MediaController : public QObject
5960
EarDetectionBehavior earDetectionBehavior = PauseWhenOneRemoved;
6061
QString m_deviceOutputName;
6162
PlayerStatusWatcher *playerStatusWatcher = nullptr;
63+
MediaState m_mediaState = Stopped;
6264
};
6365

6466
#endif // MEDIACONTROLLER_H

0 commit comments

Comments
 (0)