]> git.sur5r.net Git - minitube/blob - lib/media/src/mpv/mpvwidget.h
New upstream version 3.1
[minitube] / lib / media / src / mpv / mpvwidget.h
1 #ifndef PLAYERWINDOW_H
2 #define PLAYERWINDOW_H
3
4 #include <QtWidgets>
5 #include <mpv/client.h>
6 #include <mpv/qthelper.hpp>
7 #include <mpv/render_gl.h>
8
9 class MpvWidget Q_DECL_FINAL : public QOpenGLWidget {
10     Q_OBJECT
11
12 public:
13     MpvWidget(mpv_handle *mpv, QWidget *parent = nullptr, Qt::WindowFlags f = nullptr);
14     ~MpvWidget() Q_DECL_OVERRIDE;
15
16     QSize sizeHint() const Q_DECL_OVERRIDE { return QSize(480, 270); }
17
18 protected:
19     void initializeGL() Q_DECL_OVERRIDE;
20     void resizeGL(int w, int h) Q_DECL_OVERRIDE;
21     void paintGL() Q_DECL_OVERRIDE;
22
23 private slots:
24     void maybeUpdate();
25     void onFrameSwapped();
26
27 private:
28     static void onUpdate(void *ctx);
29
30     mpv_handle *mpv;
31     mpv_render_context *mpvContext;
32     int glWidth;
33     int glHeight;
34 };
35
36 #endif // PLAYERWINDOW_H