diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/Scale.hpp | 9 | ||||
-rw-r--r-- | include/VideoPlayer.hpp | 11 |
2 files changed, 16 insertions, 4 deletions
diff --git a/include/Scale.hpp b/include/Scale.hpp new file mode 100644 index 0000000..4ab2882 --- /dev/null +++ b/include/Scale.hpp @@ -0,0 +1,9 @@ +#pragma once + +#include <SFML/System/Vector2.hpp> + +namespace QuickMedia { + sf::Vector2f wrap_to_size(const sf::Vector2f &size, const sf::Vector2f &clamp_size); + sf::Vector2f clamp_to_size(const sf::Vector2f &size, const sf::Vector2f &clamp_size); + sf::Vector2f get_ratio(const sf::Vector2f &original_size, const sf::Vector2f &new_size); +}
\ No newline at end of file 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; }; } |