f7b7cdbfd5
By creating a DBus connection per player, we are able to support multiple remote players. The album art is not yet supported.
97 lines
3.1 KiB
C++
97 lines
3.1 KiB
C++
/**
|
|
* Copyright 2019 Matthijs Tijink <matthijstijink@gmail.com>
|
|
*
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU General Public License as
|
|
* published by the Free Software Foundation; either version 2 of
|
|
* the License or (at your option) version 3 or any later version
|
|
* accepted by the membership of KDE e.V. (or its successor approved
|
|
* by the membership of KDE e.V.), which shall act as a proxy
|
|
* defined in Section 14 of version 3 of the license.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
*/
|
|
#pragma once
|
|
|
|
#include <QDBusAbstractAdaptor>
|
|
#include <QDBusObjectPath>
|
|
#include <QVariantMap>
|
|
|
|
class MprisRemotePlayer;
|
|
class MprisRemotePlugin;
|
|
|
|
class MprisRemotePlayerMediaPlayer2Player : public QDBusAbstractAdaptor {
|
|
Q_OBJECT
|
|
Q_CLASSINFO("D-Bus Interface", "org.mpris.MediaPlayer2.Player")
|
|
|
|
Q_PROPERTY(QString PlaybackStatus READ PlaybackStatus)
|
|
Q_PROPERTY(double Rate READ Rate CONSTANT)
|
|
Q_PROPERTY(QVariantMap Metadata READ Metadata)
|
|
Q_PROPERTY(double Volume READ Volume WRITE setVolume)
|
|
Q_PROPERTY(qlonglong Position READ Position)
|
|
Q_PROPERTY(double MinimumRate READ MinimumRate)
|
|
Q_PROPERTY(double MaximumRate READ MaximumRate)
|
|
Q_PROPERTY(bool CanGoNext READ CanGoNext)
|
|
Q_PROPERTY(bool CanGoPrevious READ CanGoPrevious)
|
|
Q_PROPERTY(bool CanPlay READ CanPlay)
|
|
Q_PROPERTY(bool CanPause READ CanPause)
|
|
Q_PROPERTY(bool CanSeek READ CanSeek CONSTANT)
|
|
Q_PROPERTY(bool CanControl READ CanControl CONSTANT)
|
|
|
|
public:
|
|
explicit MprisRemotePlayerMediaPlayer2Player(MprisRemotePlayer *parent, MprisRemotePlugin *plugin);
|
|
~MprisRemotePlayerMediaPlayer2Player();
|
|
|
|
public Q_SLOTS:
|
|
void Next();
|
|
void Previous();
|
|
void Pause();
|
|
void PlayPause();
|
|
void Stop();
|
|
void Play();
|
|
void Seek(qlonglong Offset);
|
|
void SetPosition(QDBusObjectPath TrackId, qlonglong Position);
|
|
void OpenUri(QString Uri);
|
|
|
|
public:
|
|
QString PlaybackStatus() const;
|
|
double Rate() const;
|
|
QVariantMap Metadata() const;
|
|
double Volume() const;
|
|
void setVolume(double volume) const;
|
|
qlonglong Position() const;
|
|
double MinimumRate() const;
|
|
double MaximumRate() const;
|
|
bool CanGoNext() const;
|
|
bool CanGoPrevious() const;
|
|
bool CanPlay() const;
|
|
bool CanPause() const;
|
|
bool CanSeek() const;
|
|
bool CanControl() const;
|
|
|
|
Q_SIGNALS:
|
|
void Seeked(qlonglong position);
|
|
|
|
private:
|
|
MprisRemotePlayer *m_parent;
|
|
MprisRemotePlugin *m_plugin;
|
|
|
|
bool m_controlsChanged;
|
|
bool m_trackInfoChanged;
|
|
bool m_positionChanged;
|
|
bool m_volumeChanged;
|
|
bool m_playingChanged;
|
|
|
|
void controlsChanged();
|
|
void trackInfoChanged();
|
|
void positionChanged();
|
|
void volumeChanged();
|
|
void playingChanged();
|
|
void emitPropertiesChanged();
|
|
};
|