File indexing completed on 2025-01-05 04:29:50
0001 /** 0002 * SPDX-FileCopyrightText: 2022-2023 Bart De Vries <bart@mogwai.be> 0003 * 0004 * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0005 */ 0006 0007 #pragma once 0008 0009 #include <memory> 0010 0011 #include <QMediaPlayer> 0012 #include <QObject> 0013 #include <QString> 0014 #include <QUrl> 0015 0016 #include "abstractmediabackend.h" 0017 #include "kmediasession.h" 0018 0019 class QtMediaBackendPrivate; 0020 0021 class QtMediaBackend : public AbstractMediaBackend 0022 { 0023 Q_OBJECT 0024 0025 public: 0026 QtMediaBackend(QObject *parent); 0027 ~QtMediaBackend(); 0028 0029 KMediaSession::MediaBackends backend() const override; 0030 0031 bool muted() const override; 0032 qreal volume() const override; 0033 QUrl source() const override; 0034 KMediaSession::MediaStatus mediaStatus() const override; 0035 KMediaSession::PlaybackState playbackState() const override; 0036 qreal playbackRate() const override; 0037 KMediaSession::Error error() const override; 0038 qint64 duration() const override; 0039 qint64 position() const override; 0040 bool seekable() const override; 0041 0042 public Q_SLOTS: 0043 void setMuted(bool muted) override; 0044 void setVolume(qreal volume) override; 0045 void setSource(const QUrl &source) override; 0046 void setPosition(qint64 position) override; 0047 void setPlaybackRate(qreal rate) override; 0048 0049 void play() override; 0050 void pause() override; 0051 void stop() override; 0052 0053 private: 0054 friend class QtMediaBackendPrivate; 0055 std::unique_ptr<QtMediaBackendPrivate> d; 0056 0057 void playerMutedSignalChanges(bool muted); 0058 void mediaStatusSignalChanges(const QMediaPlayer::MediaStatus &qtMediaStatus); 0059 void playerVolumeSignalChanges(float volume); 0060 void playerSourceSignalChanges(const QUrl &media); 0061 void playerStateSignalChanges(const QMediaPlayer::PlaybackState &qtPlaybackState); 0062 void playerPlaybackRateSignalChanges(const qreal &playbackRate); 0063 void playerErrorSignalChanges(const QMediaPlayer::Error &error); 0064 void playerDurationSignalChanges(qint64 newDuration); 0065 void playerPositionSignalChanges(qint64 newPosition); 0066 void playerSeekableSignalChanges(bool isSeekable); 0067 void playerMetaDataSignalChanges(); 0068 };