File indexing completed on 2024-04-14 04:51:47

0001 /**
0002  * SPDX-FileCopyrightText: 2018 Nicolas Fella <nicolas.fella@gmx.de>
0003  *
0004  * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0005  */
0006 #pragma once
0007 
0008 #include <QDBusConnection>
0009 #include <QString>
0010 
0011 class NetworkPacket;
0012 class MprisRemotePlugin;
0013 
0014 class MprisRemotePlayer : public QObject
0015 {
0016     Q_OBJECT
0017 
0018 public:
0019     explicit MprisRemotePlayer(QString id, MprisRemotePlugin *plugin);
0020     ~MprisRemotePlayer() override;
0021 
0022     void parseNetworkPacket(const NetworkPacket &np);
0023     long position() const;
0024     void setPosition(long position);
0025     int volume() const;
0026     long length() const;
0027     bool playing() const;
0028     QString title() const;
0029     QString artist() const;
0030     QString album() const;
0031     QString identity() const;
0032 
0033     bool canSeek() const;
0034     bool canPlay() const;
0035     bool canPause() const;
0036     bool canGoPrevious() const;
0037     bool canGoNext() const;
0038 
0039     QDBusConnection &dbus();
0040 
0041 Q_SIGNALS:
0042     void controlsChanged();
0043     void trackInfoChanged();
0044     void positionChanged();
0045     void volumeChanged();
0046     void playingChanged();
0047 
0048 private:
0049     QString id;
0050     bool m_playing;
0051     bool m_canPlay;
0052     bool m_canPause;
0053     bool m_canGoPrevious;
0054     bool m_canGoNext;
0055     int m_volume;
0056     long m_length;
0057     long m_lastPosition;
0058     qint64 m_lastPositionTime;
0059     QString m_title;
0060     QString m_artist;
0061     QString m_album;
0062     bool m_canSeek;
0063 
0064     // Use an unique connection for every player, otherwise we can't distinguish which mpris player is being controlled
0065     QString m_dbusConnectionName;
0066     QDBusConnection m_dbusConnection;
0067 };