diff options
author | dec05eba <dec05eba@protonmail.com> | 2019-08-07 23:46:24 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2019-08-07 23:46:27 +0200 |
commit | e745c2239b8bcd30e75af27de5067dbcb1707ac1 (patch) | |
tree | aa15d0452b8d26fd255880defb056c4bb13add52 /include/VideoPlayer.hpp | |
parent | 852c6bc48b7044c54923b722ab5d9363a27ceb6c (diff) |
Correctly scale images and video to window size
Diffstat (limited to 'include/VideoPlayer.hpp')
-rw-r--r-- | include/VideoPlayer.hpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/include/VideoPlayer.hpp b/include/VideoPlayer.hpp index 6bd8f4f..0ae05b0 100644 --- a/include/VideoPlayer.hpp +++ b/include/VideoPlayer.hpp @@ -1,6 +1,7 @@ #pragma once #include <SFML/Graphics/RenderWindow.hpp> +#include <SFML/Window/Event.hpp> #include <SFML/Graphics/Texture.hpp> #include <SFML/Graphics/Sprite.hpp> #include <SFML/Graphics/RectangleShape.hpp> @@ -25,11 +26,12 @@ namespace QuickMedia { class VideoPlayer { public: // Throws VideoInitializationException on error - VideoPlayer(unsigned int width, unsigned int height, sf::WindowHandle window_handle, const char *file, bool loop = false); + VideoPlayer(sf::RenderWindow &window, unsigned int width, unsigned int height, const char *file, bool loop = false); ~VideoPlayer(); + void handleEvent(sf::Event &event); void setPosition(float x, float y); - void resize(const sf::Vector2i &size); + void resize(const sf::Vector2f &size); void draw(sf::RenderWindow &window); // @path can also be an url if youtube-dl is installed @@ -40,7 +42,7 @@ namespace QuickMedia { std::atomic_bool event_update; PlaybackEndedCallback onPlaybackEndedCallback; private: - void handle_events(); + void handle_mpv_events(); private: mpv_handle *mpv; mpv_render_context *mpvGl; @@ -49,8 +51,9 @@ namespace QuickMedia { sf::Texture texture; sf::Uint8 *textureBuffer; sf::Vector2i video_size; - sf::Vector2i desired_size; + sf::Vector2f desired_size; sf::RectangleShape seekbar; sf::RectangleShape seekbar_background; + sf::Clock cursor_last_active_timer; }; } |