]> git.sur5r.net Git - minitube/blob - lib/media/src/mpv/mediampv.h
New upstream version 3.1
[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     QString file() const;
30     void setBufferMilliseconds(qint64 value);
31     void setUserAgent(const QString &value);
32     void enqueue(const QString &file);
33     void clearQueue();
34     bool hasQueue() const;
35     qint64 position() const;
36     qint64 duration() const;
37     qint64 remainingTime() const;
38     qreal volume() const;
39     void setVolume(qreal value);
40     bool volumeMuted() const;
41     void setVolumeMuted(bool value);
42     QString errorString() const;
43
44 private slots:
45     void onMpvEvents();
46     void checkAboutToFinish(qint64 position);
47
48 signals:
49     void mpvEvents();
50
51 private:
52     void handleMpvEvent(mpv_event *event);
53     void sendCommand(const char *args[]);
54     void setState(Media::State value);
55     void clearTrackState();
56
57     QWidget *widget;
58     mpv_handle *mpv;
59     Media::State currentState = Media::StoppedState;
60     bool aboutToFinishEmitted = false;
61     QString lastErrorString;
62 };
63
64 #endif // MEDIAMPV_H