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 <memory>
0013 
0014 #include <QObject>
0015 #include <QSharedPointer>
0016 
0017 #if !defined Q_OS_ANDROID
0018 class MediaPlayer2Player;
0019 class MediaPlayer2;
0020 #endif
0021 class KMediaSession;
0022 
0023 class Mpris2 : public QObject
0024 {
0025     Q_OBJECT
0026 
0027     Q_PROPERTY(bool showProgressOnTaskBar READ showProgressOnTaskBar WRITE setShowProgressOnTaskBar NOTIFY showProgressOnTaskBarChanged)
0028 
0029 public:
0030     explicit Mpris2(QObject *parent = nullptr);
0031     ~Mpris2() override;
0032 
0033     [[nodiscard]] bool showProgressOnTaskBar() const;
0034 
0035 public Q_SLOTS:
0036     void setShowProgressOnTaskBar(bool value);
0037 
0038 Q_SIGNALS:
0039     void showProgressOnTaskBarChanged();
0040 
0041 private:
0042     void initDBusService(const QString &playerName);
0043     bool unregisterDBusService(const QString &playerName);
0044 
0045 #if !defined Q_OS_ANDROID
0046     std::unique_ptr<MediaPlayer2> m_mp2;
0047     std::unique_ptr<MediaPlayer2Player> m_mp2p;
0048 #endif
0049 
0050     KMediaSession *m_audioPlayer = nullptr;
0051     bool m_ShowProgressOnTaskBar = true;
0052     QString m_playerName;
0053 };