Debian Codegraph @

src/librssguard/gui/mediaplayer/qtmultimedia/qtmultimediabackend.h

raw symbols SCIP
1 // For license of this file, see <project-root-folder>/LICENSE.md.
2
3 #ifndef QTMULTIMEDIABACKEND_H
4 #define QTMULTIMEDIABACKEND_H
5
6 #include "gui/mediaplayer/playerbackend.h"
7
8 #include <QMediaPlayer>
9 #include <QObject>
10
11 #if QT_VERSION_MAJOR == 6
12 #define PLAYBACK_STATE PlaybackState
13 #define PLAYBACK_STATE_METHOD playbackState
14 #else
15 #define PLAYBACK_STATE State
16 #define PLAYBACK_STATE_METHOD state
17 #endif
18
19 #if QT_VERSION_MAJOR == 6
20 class QAudioOutput;
21 #endif
22
23 class QVideoWidget;
24
25 class QtMultimediaBackend : public PlayerBackend {
26 Q_OBJECT
27
28 public:
29 explicit QtMultimediaBackend(Application* app, QWidget* parent = nullptr);
30
31 virtual QUrl url() const;
32 virtual int position() const;
33 virtual int duration() const;
34
35 public slots:
36 virtual void playUrl(const QUrl& url);
37 virtual void playPause();
38 virtual void pause();
39 virtual void stop();
40
41 virtual void setPlaybackSpeed(int speed);
42 virtual void setVolume(int volume);
43 virtual void setPosition(int position);
44 virtual void setFullscreen(bool fullscreen);
45 virtual void setMuted(bool muted);
46
47 private slots:
48 void onPlaybackRateChanged(qreal speed);
49 void onDurationChanged(qint64 duration);
50 void onErrorOccurred(QMediaPlayer::Error error, const QString& error_string = {});
51 void onAudioAvailable(bool available);
52 void onVideoAvailable(bool available);
53 void onMediaStatusChanged(QMediaPlayer::MediaStatus status);
54 void onPlaybackStateChanged(QMediaPlayer::PLAYBACK_STATE state);
55 void onPositionChanged(qint64 position);
56 void onSeekableChanged(bool seekable);
57
58 private:
59 int convertToSliderVolume(float volume) const;
60 float convertSliderVolume(int slider_volume) const;
61 qint64 convertSliderProgress(int slider_progress) const;
62 int convertToSliderProgress(qint64 player_progress) const;
63 int convertDuration(qint64 duration) const;
64 qreal convertSpeed(int speed) const;
65 int convertSpinSpeed(qreal speed) const;
66
67 QString errorToString(QMediaPlayer::Error error) const;
68 QString mediaStatusToString(QMediaPlayer::MediaStatus status) const;
69
70 private:
71 #if QT_VERSION_MAJOR == 6
72 QAudioOutput* m_audio;
73 #endif
74
75 QMediaPlayer* m_player;
76 QVideoWidget* m_video;
77 int m_volume;
78 };
79
80 #endif // QTMULTIMEDIABACKEND_H