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 <QObject>
0010 #include <QUrl>
0011 
0012 #include "kmediasession.h"
0013 
0014 class AbstractMediaBackend : public QObject
0015 {
0016     Q_OBJECT
0017 
0018 public:
0019     inline AbstractMediaBackend(QObject *parent)
0020         : QObject(parent){};
0021     inline ~AbstractMediaBackend(){};
0022 
0023     virtual KMediaSession::MediaBackends backend() const = 0;
0024 
0025     virtual bool muted() const = 0;
0026     virtual qreal volume() const = 0;
0027     virtual QUrl source() const = 0;
0028     virtual KMediaSession::MediaStatus mediaStatus() const = 0;
0029     virtual KMediaSession::PlaybackState playbackState() const = 0;
0030     virtual qreal playbackRate() const = 0;
0031     virtual KMediaSession::Error error() const = 0;
0032     virtual qint64 duration() const = 0;
0033     virtual qint64 position() const = 0;
0034     virtual bool seekable() const = 0;
0035 
0036 Q_SIGNALS:
0037     /* In the derived class, make sure to only emit the signals from this
0038      * abstract class. It is not needed to re-define (nor emit) these signals
0039      * in the derived class.
0040      */
0041     void mutedChanged(bool muted);
0042     void volumeChanged(qreal volume);
0043     void sourceChanged(const QUrl &source);
0044     void mediaStatusChanged(KMediaSession::MediaStatus status);
0045     void playbackStateChanged(KMediaSession::PlaybackState state);
0046     void playbackRateChanged(qreal rate);
0047     void errorChanged(KMediaSession::Error error);
0048     void durationChanged(qint64 duration);
0049     void positionChanged(qint64 position);
0050     void seekableChanged(bool seekable);
0051 
0052 public Q_SLOTS:
0053     virtual void setMuted(bool muted) = 0;
0054     virtual void setVolume(qreal volume) = 0;
0055     virtual void setSource(const QUrl &source) = 0;
0056     virtual void setPosition(qint64 position) = 0;
0057     virtual void setPlaybackRate(qreal rate) = 0;
0058 
0059     virtual void play() = 0;
0060     virtual void pause() = 0;
0061     virtual void stop() = 0;
0062 };