From b694b38b407d145fcad37ae10b618310d955d267 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Fri, 23 Oct 2020 23:07:59 +0200 Subject: Add video loading animation --- src/QuickMedia.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp index 33ebb06..054b3ed 100644 --- a/src/QuickMedia.cpp +++ b/src/QuickMedia.cpp @@ -1640,10 +1640,10 @@ namespace QuickMedia { sf::RectangleShape rect; rect.setFillColor(sf::Color::Red); - // Clear screen before playing video, to show a black screen instead of being frozen - // at the previous UI for a moment - window.clear(); - window.display(); + + sf::Sprite load_sprite(loading_icon); + sf::Vector2u loading_icon_size = loading_icon.getSize(); + load_sprite.setOrigin(loading_icon_size.x * 0.5f, loading_icon_size.y * 0.5f); XEvent xev; bool cursor_visible = true; @@ -1782,7 +1782,14 @@ namespace QuickMedia { break; } - // TODO: Show loading video animation. load_video needs to be made asynchronous first + if(!video_loaded) { + window.clear(back_color); + load_sprite.setPosition(window_size.x * 0.5f - loading_icon_size.x * 0.5f, window_size.y * 0.5f - loading_icon_size.y * 0.5f); + load_sprite.setRotation(-time_watched_timer.getElapsedTime().asSeconds() * 400.0); + window.draw(load_sprite); + window.display(); + continue; + } /* Only save recommendations for the video if we have been watching it for 15 seconds */ if(is_youtube && video_loaded && !added_recommendations && time_watched_timer.getElapsedTime().asSeconds() >= 15) { -- cgit v1.2.3