2018-04-27 23:22:45 +01:00
|
|
|
/**
|
2020-08-17 10:48:10 +01:00
|
|
|
* SPDX-FileCopyrightText: 2018 Nicolas Fella <nicolas.fella@gmx.de>
|
2018-04-27 23:22:45 +01:00
|
|
|
*
|
2020-08-17 10:48:10 +01:00
|
|
|
* SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
|
2018-04-27 23:22:45 +01:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2024-07-31 17:39:28 +01:00
|
|
|
#include "albumart_cache.h"
|
2019-07-25 22:40:58 +01:00
|
|
|
#include <QDBusConnection>
|
2022-09-10 22:23:52 +01:00
|
|
|
#include <QString>
|
2024-07-31 17:39:28 +01:00
|
|
|
#include <QUrl>
|
2018-04-27 23:22:45 +01:00
|
|
|
|
2019-02-03 00:44:22 +00:00
|
|
|
class NetworkPacket;
|
2019-07-25 22:40:58 +01:00
|
|
|
class MprisRemotePlugin;
|
2019-02-03 00:44:22 +00:00
|
|
|
|
2022-09-10 22:23:52 +01:00
|
|
|
class MprisRemotePlayer : public QObject
|
|
|
|
{
|
2019-07-25 22:40:58 +01:00
|
|
|
Q_OBJECT
|
2018-04-27 23:22:45 +01:00
|
|
|
|
|
|
|
public:
|
2019-07-25 22:40:58 +01:00
|
|
|
explicit MprisRemotePlayer(QString id, MprisRemotePlugin *plugin);
|
2021-10-27 05:53:06 +01:00
|
|
|
~MprisRemotePlayer() override;
|
2018-04-27 23:22:45 +01:00
|
|
|
|
2022-09-10 22:23:52 +01:00
|
|
|
void parseNetworkPacket(const NetworkPacket &np);
|
2018-04-27 23:22:45 +01:00
|
|
|
long position() const;
|
|
|
|
void setPosition(long position);
|
2024-07-31 17:39:28 +01:00
|
|
|
void setLocalAlbumArtUrl(const QSharedPointer<LocalFile> &url);
|
2018-04-27 23:22:45 +01:00
|
|
|
int volume() const;
|
|
|
|
long length() const;
|
|
|
|
bool playing() const;
|
|
|
|
QString title() const;
|
|
|
|
QString artist() const;
|
|
|
|
QString album() const;
|
2024-07-31 17:39:28 +01:00
|
|
|
QString albumArtUrl() const;
|
|
|
|
QUrl localAlbumArtUrl() const;
|
2019-07-25 22:40:58 +01:00
|
|
|
QString identity() const;
|
2018-04-27 23:22:45 +01:00
|
|
|
|
2019-07-25 22:40:58 +01:00
|
|
|
bool canSeek() const;
|
2019-07-19 21:08:56 +01:00
|
|
|
bool canPlay() const;
|
|
|
|
bool canPause() const;
|
|
|
|
bool canGoPrevious() const;
|
|
|
|
bool canGoNext() const;
|
|
|
|
|
2019-07-25 22:40:58 +01:00
|
|
|
QDBusConnection &dbus();
|
|
|
|
|
|
|
|
Q_SIGNALS:
|
|
|
|
void controlsChanged();
|
|
|
|
void trackInfoChanged();
|
|
|
|
void positionChanged();
|
|
|
|
void volumeChanged();
|
|
|
|
void playingChanged();
|
|
|
|
|
2024-07-31 17:39:28 +01:00
|
|
|
private:
|
|
|
|
void albumArtFetched(const QString &player, const QString &remoteUrl, const QSharedPointer<LocalFile> &localPath);
|
|
|
|
|
2018-04-27 23:22:45 +01:00
|
|
|
private:
|
|
|
|
QString id;
|
|
|
|
bool m_playing;
|
2019-07-19 21:08:56 +01:00
|
|
|
bool m_canPlay;
|
|
|
|
bool m_canPause;
|
|
|
|
bool m_canGoPrevious;
|
|
|
|
bool m_canGoNext;
|
2018-04-27 23:22:45 +01:00
|
|
|
int m_volume;
|
|
|
|
long m_length;
|
|
|
|
long m_lastPosition;
|
|
|
|
qint64 m_lastPositionTime;
|
|
|
|
QString m_title;
|
|
|
|
QString m_artist;
|
|
|
|
QString m_album;
|
2024-07-31 17:39:28 +01:00
|
|
|
QString m_albumArtUrl;
|
|
|
|
// hold a strong reference so that the file doesn't get deleted while in use
|
|
|
|
QSharedPointer<LocalFile> m_localAlbumArtUrl;
|
|
|
|
|
|
|
|
private:
|
2019-07-17 22:19:53 +01:00
|
|
|
bool m_canSeek;
|
2019-07-25 22:40:58 +01:00
|
|
|
|
2022-09-10 22:23:52 +01:00
|
|
|
// Use an unique connection for every player, otherwise we can't distinguish which mpris player is being controlled
|
2019-07-25 22:40:58 +01:00
|
|
|
QString m_dbusConnectionName;
|
|
|
|
QDBusConnection m_dbusConnection;
|
2018-04-27 23:22:45 +01:00
|
|
|
};
|