]> git.sur5r.net Git - minitube/blob - lib/media/src/mpv/mediampv.h
New upstream version 3.8
[minitube] / lib / media / src / mpv / mediampv.h
1 #ifndef MEDIAMPV_H
2 #define MEDIAMPV_H
3
4 #include <QtCore>
5
6 #include "media.h"
7 #include <mpv/client.h>
8
9 class MediaMPV : public Media {
10     Q_OBJECT
11
12 public:
13     MediaMPV(QObject *parent = nullptr);
14
15     void setAudioOnly(bool value);
16 #ifndef MEDIA_AUDIOONLY
17     void setRenderer(const QString &name);
18     QWidget *videoWidget();
19     void playSeparateAudioAndVideo(const QString &video, const QString &audio);
20     void snapshot();
21 #endif
22     void init();
23     Media::State state() const;
24     void play(const QString &file);
25     void play();
26     void pause();
27     void stop();
28     void seek(qint64 ms);
29     void relativeSeek(qint64 ms);
30     QString file() const;
31     void setBufferMilliseconds(qint64 value);
32     void setUserAgent(const QString &value);
33     void enqueue(const QString &file);
34     void clearQueue();
35     bool hasQueue() const;
36     qint64 position() const;
37     qint64 duration() const;
38     qint64 remainingTime() const;
39     qreal volume() const;
40     void setVolume(qreal value);
41     bool volumeMuted() const;
42     void setVolumeMuted(bool value);
43     QString errorString() const;
44
45 private slots:
46     void onMpvEvents();
47     void checkAboutToFinish(qint64 position);
48
49 signals:
50     void mpvEvents();
51
52 private:
53     void handleMpvEvent(mpv_event *event);
54     void sendCommand(const char *args[]);
55     void setState(Media::State value);
56     void clearTrackState();
57
58     QWidget *widget;
59     mpv_handle *mpv;
60     Media::State currentState = Media::StoppedState;
61     bool aboutToFinishEmitted = false;
62     QString lastErrorString;
63
64     QString audioFileToAdd;
65 };
66
67 #endif // MEDIAMPV_H