]> git.sur5r.net Git - minitube/blob - lib/media/src/qtav/mediaqtav.h
New upstream version 3.8
[minitube] / lib / media / src / qtav / mediaqtav.h
1 #ifndef MEDIAQTAV_H
2 #define MEDIAQTAV_H
3
4 #include "media.h"
5
6 #include <QtAV>
7 #ifndef MEDIA_AUDIOONLY
8 #include <QtAVWidgets>
9 #include <QtWidgets>
10 #endif
11
12 class MediaQtAV : public Media {
13     Q_OBJECT
14
15 public:
16     MediaQtAV(QObject *parent = nullptr);
17 #ifndef MEDIA_AUDIOONLY
18     void setRenderer(const QString &name);
19     QWidget *videoWidget();
20     void playSeparateAudioAndVideo(const QString &video, const QString &audio);
21     void snapshot();
22 #endif
23     void setAudioOnly(bool value);
24     void init();
25
26     Media::State state() const;
27
28     void play(const QString &file);
29     void play();
30     void pause();
31     void stop();
32     void seek(qint64 ms);
33     void relativeSeek(qint64 ms);
34     QString file() const;
35
36     void setBufferMilliseconds(qint64 value);
37     void setUserAgent(const QString &value);
38
39     void enqueue(const QString &file);
40     void clearQueue();
41     bool hasQueue() const;
42
43     qint64 position() const;
44     qint64 duration() const;
45     qint64 remainingTime() const;
46
47     qreal volume() const;
48     void setVolume(qreal value);
49
50     bool volumeMuted() const;
51     void setVolumeMuted(bool value);
52
53     QString errorString() const;
54
55 private slots:
56     void checkAboutToFinish(qint64 position);
57     void onMediaStatusChange(QtAV::MediaStatus status);
58     void onAVError(const QtAV::AVError &e);
59
60 private:
61     QtAV::AVPlayer *createPlayer(bool audioOnly);
62     void connectPlayer(QtAV::AVPlayer *player);
63     void setCurrentPlayer(QtAV::AVPlayer *player);
64     void smoothSourceChange(const QString &file, const QString &externalAudio);
65
66     QtAV::AVPlayer *player1;
67     QtAV::AVPlayer *player2;
68     QtAV::AVPlayer *currentPlayer;
69
70     QQueue<QString> queue;
71     bool aboutToFinishEmitted = false;
72     QString lastErrorString;
73
74 #ifndef MEDIA_AUDIOONLY
75     QtAV::VideoRendererId rendererId;
76 #endif
77     bool audioOnly = false;
78 };
79
80 #endif // MEDIAQTAV_H