]> git.sur5r.net Git - minitube/blob - lib/media/src/qtav/mediaqtav.h
New upstream version 3.1
[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     QString file() const;
34
35     void setBufferMilliseconds(qint64 value);
36     void setUserAgent(const QString &value);
37
38     void enqueue(const QString &file);
39     void clearQueue();
40     bool hasQueue() const;
41
42     qint64 position() const;
43     qint64 duration() const;
44     qint64 remainingTime() const;
45
46     qreal volume() const;
47     void setVolume(qreal value);
48
49     bool volumeMuted() const;
50     void setVolumeMuted(bool value);
51
52     QString errorString() const;
53
54 private slots:
55     void checkAboutToFinish(qint64 position);
56     void onMediaStatusChange(QtAV::MediaStatus status);
57     void onAVError(const QtAV::AVError &e);
58
59 private:
60     QtAV::AVPlayer *createPlayer(bool audioOnly);
61     void connectPlayer(QtAV::AVPlayer *player);
62     void setCurrentPlayer(QtAV::AVPlayer *player);
63     void smoothSourceChange(const QString &file, const QString &externalAudio);
64
65     QtAV::AVPlayer *player1;
66     QtAV::AVPlayer *player2;
67     QtAV::AVPlayer *currentPlayer;
68
69     QQueue<QString> queue;
70     bool aboutToFinishEmitted = false;
71     QString lastErrorString;
72
73 #ifndef MEDIA_AUDIOONLY
74     QtAV::VideoRendererId rendererId;
75 #endif
76     bool audioOnly = false;
77 };
78
79 #endif // MEDIAQTAV_H