]> git.sur5r.net Git - minitube/blobdiff - lib/media/src/mpv/mpvwidget.h
New upstream version 3.1
[minitube] / lib / media / src / mpv / mpvwidget.h
diff --git a/lib/media/src/mpv/mpvwidget.h b/lib/media/src/mpv/mpvwidget.h
new file mode 100644 (file)
index 0000000..c647311
--- /dev/null
@@ -0,0 +1,36 @@
+#ifndef PLAYERWINDOW_H
+#define PLAYERWINDOW_H
+
+#include <QtWidgets>
+#include <mpv/client.h>
+#include <mpv/qthelper.hpp>
+#include <mpv/render_gl.h>
+
+class MpvWidget Q_DECL_FINAL : public QOpenGLWidget {
+    Q_OBJECT
+
+public:
+    MpvWidget(mpv_handle *mpv, QWidget *parent = nullptr, Qt::WindowFlags f = nullptr);
+    ~MpvWidget() Q_DECL_OVERRIDE;
+
+    QSize sizeHint() const Q_DECL_OVERRIDE { return QSize(480, 270); }
+
+protected:
+    void initializeGL() Q_DECL_OVERRIDE;
+    void resizeGL(int w, int h) Q_DECL_OVERRIDE;
+    void paintGL() Q_DECL_OVERRIDE;
+
+private slots:
+    void maybeUpdate();
+    void onFrameSwapped();
+
+private:
+    static void onUpdate(void *ctx);
+
+    mpv_handle *mpv;
+    mpv_render_context *mpvContext;
+    int glWidth;
+    int glHeight;
+};
+
+#endif // PLAYERWINDOW_H