summaryrefslogtreecommitdiff
path: root/src/mpris2
diff options
context:
space:
mode:
authorMateusz Łukasik <mati75@linuxmint.pl>2018-03-12 05:45:30 -0400
committerMateusz Łukasik <mati75@linuxmint.pl>2018-03-12 05:45:30 -0400
commitddef07cab834612d6470fbb4483afde40cd2d708 (patch)
tree183ca1da081ae14e3e05d7ae4374c484e0ff9def /src/mpris2
Import smplayer_18.2.2~ds0.orig.tar.bz2
[dgit import orig smplayer_18.2.2~ds0.orig.tar.bz2]
Diffstat (limited to 'src/mpris2')
-rw-r--r--src/mpris2/mediaplayer2.cpp116
-rw-r--r--src/mpris2/mediaplayer2.h96
-rw-r--r--src/mpris2/mediaplayer2player.cpp273
-rw-r--r--src/mpris2/mediaplayer2player.h123
-rw-r--r--src/mpris2/mpris2.cpp95
-rw-r--r--src/mpris2/mpris2.h60
6 files changed, 763 insertions, 0 deletions
diff --git a/src/mpris2/mediaplayer2.cpp b/src/mpris2/mediaplayer2.cpp
new file mode 100644
index 0000000..46522a2
--- /dev/null
+++ b/src/mpris2/mediaplayer2.cpp
@@ -0,0 +1,116 @@
+/* smplayer, GUI front-end for mplayer.
+ Copyright (C) 2006-2018 Ricardo Villalba <rvm@users.sourceforge.net>
+
+ 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) 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, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+/***********************************************************************
+ * Copyright 2012 Eike Hein <hein@kde.org>
+ * Copyright 2012 Bernd Buschinski <b.buschinski@googlemail.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 <http://www.gnu.org/licenses/>.
+ ***********************************************************************/
+
+#include "mediaplayer2.h"
+#include "mpris2.h"
+#include "basegui.h"
+#include <QApplication>
+
+
+MediaPlayer2::MediaPlayer2(BaseGui* gui, QObject* parent)
+ : QDBusAbstractAdaptor(parent),
+ m_gui(gui)
+{
+// connect(m_gui, SIGNAL(fullScreen(bool)), this, SLOT(emitFullscreenChange(bool)));
+}
+
+MediaPlayer2::~MediaPlayer2() {
+}
+
+bool MediaPlayer2::CanQuit() const {
+ return true;
+}
+
+void MediaPlayer2::Quit() const {
+ qDebug("MediaPlayer2::Quit");
+ m_gui->runActions("close");
+}
+
+bool MediaPlayer2::CanRaise() const {
+ return true;
+}
+
+void MediaPlayer2::Raise() const {
+ qDebug("MediaPlayer2::Raise");
+ m_gui->raise();
+ m_gui->activateWindow();
+}
+
+bool MediaPlayer2::Fullscreen() const {
+ return m_gui->isFullScreen();
+}
+
+void MediaPlayer2::setFullscreen(bool fullscreen) const {
+ qDebug() << "MediaPlayer2::setFullscreen:" << fullscreen;
+ m_gui->toggleFullscreen(fullscreen);
+}
+
+void MediaPlayer2::emitFullscreenChange(bool fullscreen) const {
+ QVariantMap properties;
+ properties["Fullscreen"] = fullscreen;
+ Mpris2::signalPropertiesChange(this, properties);
+}
+
+bool MediaPlayer2::CanSetFullscreen() const {
+ return true;
+}
+
+bool MediaPlayer2::HasTrackList() const {
+ return false;
+}
+
+QString MediaPlayer2::Identity() const {
+ return QString("SMPlayer");
+}
+
+QString MediaPlayer2::DesktopEntry() const {
+ return QString("smplayer");
+}
+
+QStringList MediaPlayer2::SupportedUriSchemes() const {
+ //TODO: Implement me
+ return QStringList();
+}
+
+QStringList MediaPlayer2::SupportedMimeTypes() const {
+ //TODO: Implement me
+ return QStringList();
+}
+
+#include "moc_mediaplayer2.cpp"
diff --git a/src/mpris2/mediaplayer2.h b/src/mpris2/mediaplayer2.h
new file mode 100644
index 0000000..10b4a4e
--- /dev/null
+++ b/src/mpris2/mediaplayer2.h
@@ -0,0 +1,96 @@
+/* smplayer, GUI front-end for mplayer.
+ Copyright (C) 2006-2018 Ricardo Villalba <rvm@users.sourceforge.net>
+
+ 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) 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, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+
+/***********************************************************************
+ * Copyright 2012 Eike Hein <hein@kde.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 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 <http://www.gnu.org/licenses/>.
+ ***********************************************************************/
+
+#ifndef MEDIAPLAYER2_H
+#define MEDIAPLAYER2_H
+
+#include <QDBusAbstractAdaptor>
+#include <QStringList>
+
+class BaseGui;
+
+class MediaPlayer2 : public QDBusAbstractAdaptor
+{
+ Q_OBJECT
+ Q_CLASSINFO("D-Bus Interface", "org.mpris.MediaPlayer2") // Docs: http://www.mpris.org/2.1/spec/Root_Node.html
+
+ Q_PROPERTY(bool CanQuit READ CanQuit)
+ Q_PROPERTY(bool CanRaise READ CanRaise)
+
+ Q_PROPERTY(bool Fullscreen READ Fullscreen WRITE setFullscreen)
+ Q_PROPERTY(bool CanSetFullscreen READ CanSetFullscreen)
+
+ Q_PROPERTY(bool HasTrackList READ HasTrackList)
+
+ Q_PROPERTY(QString Identity READ Identity)
+ Q_PROPERTY(QString DesktopEntry READ DesktopEntry)
+
+ Q_PROPERTY(QStringList SupportedUriSchemes READ SupportedUriSchemes)
+ Q_PROPERTY(QStringList SupportedMimeTypes READ SupportedMimeTypes)
+
+ public:
+ explicit MediaPlayer2(BaseGui* gui, QObject* parent);
+ ~MediaPlayer2();
+
+ bool CanQuit() const;
+ bool CanRaise() const;
+
+ bool Fullscreen() const;
+ void setFullscreen(bool fullscreen) const;
+ bool CanSetFullscreen() const;
+
+ bool HasTrackList() const;
+
+ QString Identity() const;
+ QString DesktopEntry() const;
+
+ QStringList SupportedUriSchemes() const;
+ QStringList SupportedMimeTypes() const;
+
+ public slots:
+ void Raise() const;
+ void Quit() const;
+
+ private slots:
+ void emitFullscreenChange(bool fullscreen) const;
+ private:
+ BaseGui* m_gui;
+};
+
+#endif
diff --git a/src/mpris2/mediaplayer2player.cpp b/src/mpris2/mediaplayer2player.cpp
new file mode 100644
index 0000000..9a87982
--- /dev/null
+++ b/src/mpris2/mediaplayer2player.cpp
@@ -0,0 +1,273 @@
+/* smplayer, GUI front-end for mplayer.
+ Copyright (C) 2006-2018 Ricardo Villalba <rvm@users.sourceforge.net>
+
+ 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) 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, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+
+/***********************************************************************
+ * Copyright 2012 Eike Hein <hein@kde.org>
+ * Copyright 2012 Bernd Buschinski <b.buschinski@googlemail.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 <http://www.gnu.org/licenses/>.
+ ***********************************************************************/
+
+#include "mediaplayer2player.h"
+#include "mpris2.h"
+#include "basegui.h"
+#include "core.h"
+#include "playlist.h"
+
+#include <QCryptographicHash>
+
+static QByteArray makeTrackId(const QString& source) {
+ return QByteArray("/org/smplayer/") + "smplayer" + "/tid_" +
+ QCryptographicHash::hash(source.toLocal8Bit(), QCryptographicHash::Sha1)
+ .toHex();
+}
+
+MediaPlayer2Player::MediaPlayer2Player(BaseGui * gui, QObject* parent)
+ : QDBusAbstractAdaptor(parent),
+ m_core(gui->getCore()),
+ m_playlist(gui->getPlaylist())
+{
+ //connect(m_core, SIGNAL(tick(qint64)), this, SLOT(tick(qint64)));
+ //connect(m_core, SIGNAL(seekableChanged(bool)), this, SLOT(seekableChanged(bool)));
+ connect(m_core, SIGNAL(mediaPlaying(QString,QString)), this, SLOT(currentSourceChanged()));
+ connect(m_core, SIGNAL(stateChanged(Core::State)), this, SLOT(stateUpdated()));
+ connect(m_core, SIGNAL(mediaInfoChanged()), this, SLOT(emitMetadataChange()));
+ connect(m_core, SIGNAL(volumeChanged(int)), this, SLOT(volumeChanged()));
+}
+
+MediaPlayer2Player::~MediaPlayer2Player() {
+}
+
+bool MediaPlayer2Player::CanGoNext() const {
+ return true;
+}
+
+void MediaPlayer2Player::Next() const {
+ qDebug("MediaPlayer2Player::Next");
+ m_playlist->playNext();
+}
+
+bool MediaPlayer2Player::CanGoPrevious() const {
+ return true;
+}
+
+void MediaPlayer2Player::Previous() const {
+ qDebug("MediaPlayer2Player::Previous");
+ m_playlist->playPrev();
+}
+
+bool MediaPlayer2Player::CanPause() const {
+ return true;
+}
+
+void MediaPlayer2Player::Pause() const {
+ qDebug("MediaPlayer2Player::Pause");
+ m_core->pause();
+}
+
+void MediaPlayer2Player::PlayPause() const {
+ qDebug("MediaPlayer2Player::PlayPause");
+ m_core->play_or_pause();
+}
+
+void MediaPlayer2Player::Stop() const {
+ qDebug("MediaPlayer2Player::Stop");
+ m_core->stop();
+}
+
+bool MediaPlayer2Player::CanPlay() const {
+ return true;
+}
+
+void MediaPlayer2Player::Play() const {
+ qDebug("MediaPlayer2Player::Play");
+ m_core->play();
+}
+
+void MediaPlayer2Player::SetPosition(const QDBusObjectPath& TrackId, qlonglong Position) const {
+ double secs = Position / 1000000;
+ qDebug() << "MediaPlayer2Player::SetPosition: TrackId:" << TrackId.path() << "Position:" << Position << "(secs:" << secs << ")";
+ if (TrackId.path().toLocal8Bit() == makeTrackId(m_core->mdat.filename)) {
+ m_core->goToSec(secs);
+ }
+}
+
+void MediaPlayer2Player::OpenUri(QString uri) const {
+ qDebug() << "MediaPlayer2Player::OpenUri:" << uri;
+ m_core->open(uri);
+}
+
+QString MediaPlayer2Player::PlaybackStatus() const {
+ return m_core->stateToString();
+}
+
+QString MediaPlayer2Player::LoopStatus() const {
+ return "None";
+}
+
+void MediaPlayer2Player::setLoopStatus(const QString& loopStatus) const {
+ Q_UNUSED(loopStatus)
+}
+
+double MediaPlayer2Player::Rate() const {
+ return m_core->mset.speed;
+}
+
+void MediaPlayer2Player::setRate(double rate) const {
+ qDebug() << "MediaPlayer2Player::setRate:" << rate;
+ m_core->setSpeed(rate);
+}
+
+bool MediaPlayer2Player::Shuffle() const {
+ return false;
+}
+
+void MediaPlayer2Player::setShuffle(bool shuffle) const {
+ Q_UNUSED(shuffle)
+}
+
+QVariantMap MediaPlayer2Player::Metadata() const {
+ QVariantMap metaData;
+
+ if (!m_core->mdat.initialized) {
+ return metaData;
+ }
+
+ metaData["mpris:trackid"] = QVariant::fromValue<QDBusObjectPath>(QDBusObjectPath(makeTrackId(m_core->mdat.filename).constData()));
+ metaData["mpris:length"] = m_core->mdat.duration * 1000000;
+
+ if (m_core->mdat.type == TYPE_STREAM)
+ metaData["xesam:url"] = m_core->mdat.stream_url;
+ else
+ metaData["xesam:url"] = m_core->mdat.filename;
+
+ if (!m_core->mdat.clip_album.isEmpty())
+ metaData["xesam:album"] = m_core->mdat.clip_album;
+ if (!m_core->mdat.clip_name.isEmpty())
+ metaData["xesam:title"] = m_core->mdat.clip_name;
+ else if (!m_core->mdat.filename.isEmpty()) {
+ QFileInfo fileInfo(m_core->mdat.filename);
+ metaData["xesam:title"] = fileInfo.fileName();
+ }
+ if (!m_core->mdat.clip_artist.isEmpty())
+ metaData["xesam:artist"] = m_core->mdat.clip_artist;
+ if (!m_core->mdat.clip_genre.isEmpty())
+ metaData["xesam:genre"] = m_core->mdat.clip_genre;
+
+ return metaData;
+}
+
+double MediaPlayer2Player::Volume() const {
+ return static_cast<double>(m_core->mset.volume / 100.0);
+}
+
+void MediaPlayer2Player::setVolume(double volume) const {
+ qDebug() << "MediaPlayer2Player::setVolume:" << volume;
+ m_core->setVolume(static_cast<int>(volume*100));
+}
+
+qlonglong MediaPlayer2Player::Position() const {
+ return static_cast<qlonglong>(m_core->mset.current_sec * 1000000);
+}
+
+double MediaPlayer2Player::MinimumRate() const {
+ return 0.01;
+}
+
+double MediaPlayer2Player::MaximumRate() const {
+ return 100.0;
+}
+
+bool MediaPlayer2Player::CanSeek() const {
+ return true;
+}
+
+void MediaPlayer2Player::Seek(qlonglong Offset) const {
+ int secs = Offset/1000000;
+ qDebug() << "MediaPlayer2Player::Seek:" << Offset << "(secs" << secs << ")";
+ m_core->seek(secs);
+}
+
+bool MediaPlayer2Player::CanControl() const {
+ return true;
+}
+
+void MediaPlayer2Player::tick(qint64 newPos) {
+ /*
+ if (newPos - oldPos > tickInterval + 250 || newPos < oldPos) {
+ emit Seeked(newPos * 1000);
+ }
+ */
+
+ oldPos = newPos;
+}
+
+void MediaPlayer2Player::emitMetadataChange() const {
+ QVariantMap properties;
+ properties["Metadata"] = Metadata();
+ Mpris2::signalPropertiesChange(this, properties);
+}
+
+void MediaPlayer2Player::currentSourceChanged() const {
+ QVariantMap properties;
+ properties["Metadata"] = Metadata();
+ properties["CanSeek"] = CanSeek();
+ Mpris2::signalPropertiesChange(this, properties);
+}
+
+void MediaPlayer2Player::stateUpdated() const {
+ QVariantMap properties;
+ properties["PlaybackStatus"] = PlaybackStatus();
+ properties["CanPause"] = CanPause();
+ Mpris2::signalPropertiesChange(this, properties);
+}
+
+void MediaPlayer2Player::totalTimeChanged() const {
+ QVariantMap properties;
+ properties["Metadata"] = Metadata();
+ Mpris2::signalPropertiesChange(this, properties);
+}
+
+void MediaPlayer2Player::seekableChanged(bool seekable) const {
+ QVariantMap properties;
+ properties["CanSeek"] = seekable;
+ Mpris2::signalPropertiesChange(this, properties);
+}
+
+void MediaPlayer2Player::volumeChanged() const {
+ QVariantMap properties;
+ properties["Volume"] = Volume();
+ Mpris2::signalPropertiesChange(this, properties);
+}
+
+#include "moc_mediaplayer2player.cpp"
diff --git a/src/mpris2/mediaplayer2player.h b/src/mpris2/mediaplayer2player.h
new file mode 100644
index 0000000..2374a90
--- /dev/null
+++ b/src/mpris2/mediaplayer2player.h
@@ -0,0 +1,123 @@
+/* smplayer, GUI front-end for mplayer.
+ Copyright (C) 2006-2018 Ricardo Villalba <rvm@users.sourceforge.net>
+
+ 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) 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, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+/***********************************************************************
+ * Copyright 2012 Eike Hein <hein@kde.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 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 <http://www.gnu.org/licenses/>.
+ ***********************************************************************/
+
+#ifndef MEDIAPLAYER2PLAYER_H
+#define MEDIAPLAYER2PLAYER_H
+
+#include <QDBusAbstractAdaptor>
+#include <QDBusObjectPath>
+
+class BaseGui;
+class Core;
+class Playlist;
+
+class MediaPlayer2Player : public QDBusAbstractAdaptor
+{
+ Q_OBJECT
+ Q_CLASSINFO("D-Bus Interface", "org.mpris.MediaPlayer2.Player") // Docs: http://www.mpris.org/2.1/spec/Player_Node.html
+
+ Q_PROPERTY(QString PlaybackStatus READ PlaybackStatus)
+ Q_PROPERTY(QString LoopStatus READ LoopStatus WRITE setLoopStatus)
+ Q_PROPERTY(double Rate READ Rate WRITE setRate)
+ Q_PROPERTY(bool Shuffle READ Shuffle WRITE setShuffle)
+ 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)
+ Q_PROPERTY(bool CanControl READ CanControl)
+
+ public:
+ explicit MediaPlayer2Player(BaseGui * gui, QObject* parent);
+ ~MediaPlayer2Player();
+
+ QString PlaybackStatus() const;
+ QString LoopStatus() const;
+ void setLoopStatus(const QString& loopStatus) const;
+ double Rate() const;
+ void setRate(double rate) const;
+ bool Shuffle() const;
+ void setShuffle(bool shuffle) 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;
+
+ signals:
+ void Seeked(qlonglong Position) const;
+
+ public slots:
+ void Next() const;
+ void Previous() const;
+ void Pause() const;
+ void PlayPause() const;
+ void Stop() const;
+ void Play() const;
+ void Seek(qlonglong Offset) const;
+ void SetPosition(const QDBusObjectPath& TrackId, qlonglong Position) const;
+ void OpenUri(QString uri) const;
+
+ private slots:
+ void tick(qint64 newPos);
+ void emitMetadataChange() const;
+ void currentSourceChanged() const;
+ void stateUpdated() const;
+ void totalTimeChanged() const;
+ void seekableChanged(bool seekable) const;
+ void volumeChanged() const;
+
+ private:
+ qint64 oldPos;
+ Core* m_core;
+ Playlist* m_playlist;
+};
+
+#endif
diff --git a/src/mpris2/mpris2.cpp b/src/mpris2/mpris2.cpp
new file mode 100644
index 0000000..d91ecf9
--- /dev/null
+++ b/src/mpris2/mpris2.cpp
@@ -0,0 +1,95 @@
+/* smplayer, GUI front-end for mplayer.
+ Copyright (C) 2006-2018 Ricardo Villalba <rvm@users.sourceforge.net>
+
+ 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) 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, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+/***********************************************************************
+ * Copyright 2012 Eike Hein <hein@kde.org>
+ * Copyright 2012 Bernd Buschinski <b.buschinski@googlemail.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 <http://www.gnu.org/licenses/>.
+ ***********************************************************************/
+
+#include "mpris2.h"
+#include "mediaplayer2.h"
+#include "mediaplayer2player.h"
+
+#include <QDBusConnection>
+#include <QDBusMessage>
+#include <QMetaClassInfo>
+#include <QStringList>
+
+#include <unistd.h>
+
+// basegui.h includes windows.h which creates a conflict with QDBusConnection
+// so moved here to avoid it
+#include "basegui.h"
+
+Mpris2::Mpris2(BaseGui* gui, QObject* parent)
+ : QObject(parent)
+{
+ QString mpris2Name("org.mpris.MediaPlayer2." + QLatin1String("smplayer"));
+
+ bool success = QDBusConnection::sessionBus().registerService(mpris2Name);
+
+ // If the above failed, it's likely because we're not the first instance
+ // and the name is already taken. In that event the MPRIS2 spec wants the
+ // following:
+ if (!success)
+ success = QDBusConnection::sessionBus().registerService(mpris2Name + ".instance" + QString::number(getpid()));
+
+ if (success)
+ {
+ new MediaPlayer2(gui, this);
+ new MediaPlayer2Player(gui, this);
+ QDBusConnection::sessionBus().registerObject("/org/mpris/MediaPlayer2", this, QDBusConnection::ExportAdaptors);
+ }
+}
+
+Mpris2::~Mpris2()
+{
+}
+
+void Mpris2::signalPropertiesChange(const QObject* adaptor, const QVariantMap& properties)
+{
+ QDBusMessage msg = QDBusMessage::createSignal("/org/mpris/MediaPlayer2",
+ "org.freedesktop.DBus.Properties", "PropertiesChanged" );
+
+ QVariantList args;
+ args << adaptor->metaObject()->classInfo(0).value();
+ args << properties;
+ args << QStringList();
+
+ msg.setArguments(args);
+
+ QDBusConnection::sessionBus().send(msg);
+}
+
+#include "moc_mpris2.cpp"
diff --git a/src/mpris2/mpris2.h b/src/mpris2/mpris2.h
new file mode 100644
index 0000000..0030dfa
--- /dev/null
+++ b/src/mpris2/mpris2.h
@@ -0,0 +1,60 @@
+/* smplayer, GUI front-end for mplayer.
+ Copyright (C) 2006-2018 Ricardo Villalba <rvm@users.sourceforge.net>
+
+ 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) 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, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+
+/***********************************************************************
+ * Copyright 2012 Eike Hein <hein@kde.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 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 <http://www.gnu.org/licenses/>.
+ ***********************************************************************/
+
+#ifndef MPRIS2_H
+#define MPRIS2_H
+
+#include <QObject>
+#include <QVariantMap>
+
+class Core;
+class BaseGui;
+
+class Mpris2 : public QObject
+{
+ Q_OBJECT
+
+ public:
+ explicit Mpris2(BaseGui* gui, QObject* parent);
+ ~Mpris2();
+
+ static void signalPropertiesChange(const QObject* adaptor, const QVariantMap& properties);
+};
+
+#endif