dbus-soundrecorder/playerwatcher.h

132 lines
2.8 KiB
C
Raw Permalink Normal View History

2015-08-24 03:11:13 +02:00
#ifndef PLAYERWATCHER_H
#define PLAYERWATCHER_H
#include <c++utilities/chrono/timespan.h>
2015-08-24 03:11:13 +02:00
#include <QObject>
QT_FORWARD_DECLARE_CLASS(QDBusServiceWatcher)
class OrgFreedesktopDBusPropertiesInterface;
class OrgMprisMediaPlayer2PlayerInterface;
namespace DBusSoundRecorder {
2017-05-01 03:39:45 +02:00
class PlayerWatcher : public QObject {
2015-08-24 03:11:13 +02:00
Q_OBJECT
public:
explicit PlayerWatcher(const QString &appName, bool ignorePlaybackStatus = false, QObject *parent = nullptr);
2015-08-24 03:11:13 +02:00
2015-08-25 19:53:54 +02:00
void play();
void stop();
void pause();
void playPause();
bool isPlaying() const;
bool isPlaybackStatusIgnored() const;
bool isAd() const;
2015-08-24 03:11:13 +02:00
const QString &title() const;
const QString &album() const;
const QString &artist() const;
const QString &year() const;
const QString &genre() const;
unsigned int trackNumber() const;
2015-08-25 19:53:54 +02:00
unsigned int diskNumber() const;
2019-06-10 23:01:04 +02:00
CppUtilities::TimeSpan length() const;
void setSilent(bool silent);
2015-08-24 03:11:13 +02:00
2020-03-09 18:43:56 +01:00
Q_SIGNALS:
2015-08-24 03:11:13 +02:00
void nextSong();
2015-08-25 19:53:54 +02:00
void playbackStarted();
void playbackStopped();
2015-08-24 03:11:13 +02:00
2020-03-08 13:55:55 +01:00
private Q_SLOTS:
2015-08-24 03:11:13 +02:00
void serviceOwnerChanged(const QString &service, const QString &oldOwner, const QString &newOwner);
2015-08-25 19:53:54 +02:00
void propertiesChanged();
void notificationReceived();
2015-08-25 19:53:54 +02:00
void seeked(qlonglong pos);
2015-08-24 03:11:13 +02:00
private:
QString m_mediaPlayerInterfaceName;
QDBusServiceWatcher *m_mediaPlayerServiceWatcher;
QString m_notifyInterfaceName;
QDBusServiceWatcher *m_notifyServiceWatcher;
2015-08-24 03:11:13 +02:00
OrgFreedesktopDBusPropertiesInterface *m_propertiesInterface;
OrgMprisMediaPlayer2PlayerInterface *m_playerInterface;
2015-08-25 19:53:54 +02:00
bool m_isPlaying;
bool m_isAd;
2015-08-24 03:11:13 +02:00
QString m_title;
QString m_album;
QString m_artist;
QString m_year;
QString m_genre;
unsigned int m_trackNumber;
2015-08-25 19:53:54 +02:00
unsigned int m_diskNumber;
2019-06-10 23:01:04 +02:00
CppUtilities::TimeSpan m_length;
bool m_silent;
bool m_ignorePlaybackStatus;
2015-08-24 03:11:13 +02:00
};
2015-08-25 19:53:54 +02:00
inline bool PlayerWatcher::isPlaying() const
{
return m_isPlaying;
}
inline bool PlayerWatcher::isPlaybackStatusIgnored() const
{
return m_ignorePlaybackStatus;
}
inline bool PlayerWatcher::isAd() const
{
return m_isAd;
}
2015-08-24 03:11:13 +02:00
inline const QString &PlayerWatcher::title() const
{
return m_title;
}
inline const QString &PlayerWatcher::album() const
{
return m_album;
}
inline const QString &PlayerWatcher::artist() const
{
return m_artist;
}
inline const QString &PlayerWatcher::year() const
{
return m_year;
}
inline const QString &PlayerWatcher::genre() const
{
return m_genre;
}
inline unsigned int PlayerWatcher::trackNumber() const
{
return m_trackNumber;
}
2015-08-25 19:53:54 +02:00
inline unsigned int PlayerWatcher::diskNumber() const
{
return m_diskNumber;
}
2019-06-10 23:01:04 +02:00
inline CppUtilities::TimeSpan PlayerWatcher::length() const
2015-08-25 19:53:54 +02:00
{
return m_length;
}
inline void PlayerWatcher::setSilent(bool silent)
{
m_silent = silent;
}
2020-09-04 00:47:50 +02:00
} // namespace DBusSoundRecorder
2015-08-24 03:11:13 +02:00
#endif // PLAYERWATCHER_H