Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*
* Copyright (C) 2019 Kevin Whitaker <eyecreate@eyecreate.org>
*
* 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 3 of the License, or
* (at your option) any later version.
*
* 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 <http://www.gnu.org/licenses/>.
*/
#ifndef MPRISINTERFACE_H
#define MPRISINTERFACE_H
#include "minimediaplayer.h"
#include <QtDBus/QDBusAbstractAdaptor>
#include <QtDBus/QDBusConnection>
#include <QtDBus/QDBusObjectPath>
#include <QMap>
/**
* Simple DBus interface which registers and provides simple controls over media playing.
*/
class MPRISInterface : public QDBusAbstractAdaptor
{
Q_OBJECT
Q_CLASSINFO("D-Bus Interface","org.mpris.MediaPlayer2")
Q_PROPERTY(bool CanQuit READ CanQuit)
Q_PROPERTY(bool CanRaise READ CanRaise)
Q_PROPERTY(bool HasTrackList READ HasTrackList)
Q_PROPERTY(QString Identity READ Identity)
Q_PROPERTY(QStringList SupportedUriSchemes READ SupportedUriSchemes)
Q_PROPERTY(QStringList SupportedMimeTypes READ SupportedMimeTypes)
public:
MPRISInterface(QObject *parent = 0);
bool CanQuit();
bool CanRaise();
bool HasTrackList();
QString Identity();
QStringList SupportedUriSchemes();
QStringList SupportedMimeTypes();
public slots:
Q_NOREPLY void Raise() {};
Q_NOREPLY void Quit() {};
};
class MPRISPlayerInterface : public QDBusAbstractAdaptor
{
Q_OBJECT
Q_CLASSINFO("D-Bus Interface","org.mpris.MediaPlayer2.Player")
Q_PROPERTY(QString PlaybackStatus READ PlaybackStatus NOTIFY playbackStatusChanged)
Q_PROPERTY(double Rate READ Rate WRITE setRate)
Q_PROPERTY(QVariantMap Metadata READ Metadata NOTIFY metadataChanged)
Q_PROPERTY(double Volume READ Volume WRITE setVolume NOTIFY volumeChanged)
Q_PROPERTY(qlonglong Position READ Position NOTIFY positionChanged)
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)
Q_PROPERTY(bool CanControl READ CanControl)
public:
MPRISPlayerInterface(MiniMediaPlayer *player,QObject *parent = 0);
QString PlaybackStatus();
double Rate();
void setRate(double rate) {};
QVariantMap Metadata();
double Volume();
void setVolume(double volume);
qlonglong Position();
double MinimumRate();
double MaximumRate();
bool CanGoNext();
bool CanGoPrevious();
bool CanPlay();
bool CanPause();
bool CanSeek();
bool CanControl();
public slots:
Q_NOREPLY void Next();
Q_NOREPLY void Previous() {};
Q_NOREPLY void Pause();
Q_NOREPLY void PlayPause();
Q_NOREPLY void Stop();
Q_NOREPLY void Play();
Q_NOREPLY void Seek(qlonglong offset) {};
Q_NOREPLY void SetPosition(QDBusObjectPath trackId,qlonglong position) {};
Q_NOREPLY void OpenUri(QString uri);
signals:
void Seeked(qlonglong position); //Not used
void playbackStatusChanged(QString status);
void metadataChanged(QVariantMap metadata);
void volumeChanged(double volume);
void positionChanged(qlonglong position);
private slots:
void mediaStateChanged(bool isPlaying);
void mediaPositionChanged(qint64 position);
void mediaVolumeChanged(int volume);
void mediaPlaylistChanged(QStringList playlist);
private:
MiniMediaPlayer *player;
void dbusUpdate(QVariantMap changed);
};
#endif // MPRISINTERFACE_H