File indexing completed on 2025-01-19 04:28:11

0001 /**
0002  * SPDX-FileCopyrightText: 2014 Sujith Haridasan <sujith.haridasan@kdemail.net>
0003  * SPDX-FileCopyrightText: 2014 Ashish Madeti <ashishmadeti@gmail.com>
0004  * SPDX-FileCopyrightText: 2016 Matthieu Gallien <matthieu_gallien@yahoo.fr>
0005  * SPDX-FileCopyrightText: 2022-2023 Bart De Vries <bart@mogwai.be>
0006  *
0007  * SPDX-License-Identifier: GPL-3.0-or-later
0008  */
0009 
0010 #pragma once
0011 
0012 #include <QDBusAbstractAdaptor>
0013 #include <QStringList>
0014 
0015 #include "kmediasession.h"
0016 
0017 class MediaPlayer2 : public QDBusAbstractAdaptor
0018 {
0019     Q_OBJECT
0020     Q_CLASSINFO("D-Bus Interface", "org.mpris.MediaPlayer2") // Docs: https://specifications.freedesktop.org/mpris-spec/latest/Media_Player.html
0021 
0022     Q_PROPERTY(bool CanQuit READ CanQuit CONSTANT)
0023     Q_PROPERTY(bool CanRaise READ CanRaise CONSTANT)
0024     Q_PROPERTY(bool HasTrackList READ HasTrackList CONSTANT)
0025     Q_PROPERTY(QString Identity READ Identity CONSTANT)
0026     Q_PROPERTY(QString DesktopEntry READ DesktopEntry CONSTANT)
0027     Q_PROPERTY(QStringList SupportedUriSchemes READ SupportedUriSchemes CONSTANT)
0028     Q_PROPERTY(QStringList SupportedMimeTypes READ SupportedMimeTypes CONSTANT)
0029 
0030 public:
0031     explicit MediaPlayer2(KMediaSession *audioPlayer, QObject *parent = nullptr);
0032     ~MediaPlayer2() override;
0033 
0034     [[nodiscard]] bool CanQuit() const;
0035     [[nodiscard]] bool CanRaise() const;
0036     [[nodiscard]] bool HasTrackList() const;
0037 
0038     [[nodiscard]] QString Identity() const;
0039     [[nodiscard]] QString DesktopEntry() const;
0040 
0041     [[nodiscard]] QStringList SupportedUriSchemes() const;
0042     [[nodiscard]] QStringList SupportedMimeTypes() const;
0043 
0044 public Q_SLOTS:
0045     void Quit();
0046     void Raise();
0047 
0048 Q_SIGNALS:
0049     void raisePlayer();
0050     void quitPlayer();
0051 
0052 private:
0053     KMediaSession *m_audioPlayer = nullptr;
0054 };