From 4b24638802385816fb5f90c95f175b30ae2398a8 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sun, 4 Aug 2019 02:28:33 +0200 Subject: Add youtube video playing, page navigation --- include/VideoPlayer.hpp | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 include/VideoPlayer.hpp (limited to 'include/VideoPlayer.hpp') diff --git a/include/VideoPlayer.hpp b/include/VideoPlayer.hpp new file mode 100644 index 0000000..e98221e --- /dev/null +++ b/include/VideoPlayer.hpp @@ -0,0 +1,46 @@ +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include + +class mpv_handle; +class mpv_opengl_cb_context; + +namespace QuickMedia { + class VideoInitializationException : public std::runtime_error { + public: + VideoInitializationException(const std::string &errMsg) : std::runtime_error(errMsg) {} + }; + + class VideoPlayer { + public: + // Throws VideoInitializationException on error + VideoPlayer(unsigned int width, unsigned int height, const char *file, bool loop = false); + ~VideoPlayer(); + + void setPosition(float x, float y); + bool resize(const sf::Vector2i &size); + void draw(sf::RenderWindow &window); + + // This counter is incremented when mpv wants to redraw content + std::atomic_int redrawCounter; + private: + sf::Context context; + mpv_handle *mpv; + mpv_opengl_cb_context *mpvGl; + std::thread renderThread; + std::mutex renderMutex; + sf::Sprite sprite; + sf::Texture texture; + sf::Uint8 *textureBuffer; + bool alive; + sf::Vector2i video_size; + sf::Vector2i desired_size; + }; +} -- cgit v1.2.3