diff options
author | dec05eba <dec05eba@protonmail.com> | 2019-08-06 17:49:42 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2019-08-06 17:49:45 +0200 |
commit | 59988161a000851a4f0bc90f3fdcfe375571db35 (patch) | |
tree | bf31aa5fcea089a38bdcbb1c7577fcd00884e6a5 | |
parent | c11d8f861b0e260240ec59c423cdb440d7409ac1 (diff) |
Restart videoplayer when changing video, to fix loadfile video bug
-rw-r--r-- | src/QuickMedia.cpp | 9 | ||||
-rw-r--r-- | src/VideoPlayer.cpp | 4 |
2 files changed, 8 insertions, 5 deletions
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp index 5de8a0f..d6a369a 100644 --- a/src/QuickMedia.cpp +++ b/src/QuickMedia.cpp @@ -291,21 +291,24 @@ namespace QuickMedia { } std::vector<std::unique_ptr<BodyItem>> related_media = current_plugin->get_related_media(video_url); + bool reload = false; if(video_player) { - video_player->onPlaybackEndedCallback = [this, &related_media, &video_player]() { + video_player->onPlaybackEndedCallback = [this, &related_media, &video_player, &reload]() { if(related_media.empty()) return; video_url = related_media.front()->url; - video_player->load_file(video_url); related_media = current_plugin->get_related_media(video_url); + // TODO: This doesn't seem to work correctly right now, it causes video to become black when changing video (context reset bug). + //video_player->load_file(video_url); + reload = true; }; } sf::Clock resize_timer; sf::Event event; - while (current_page == Page::VIDEO_CONTENT) { + while (current_page == Page::VIDEO_CONTENT && !reload) { while (window.pollEvent(event)) { base_event_handler(event, Page::SEARCH_SUGGESTION); if(event.type == sf::Event::Resized) { diff --git a/src/VideoPlayer.cpp b/src/VideoPlayer.cpp index 41b6d0e..dbfcaac 100644 --- a/src/VideoPlayer.cpp +++ b/src/VideoPlayer.cpp @@ -54,11 +54,11 @@ namespace QuickMedia { onPlaybackEndedCallback(nullptr), mpv(nullptr), mpvGl(nullptr), - context(std::make_unique<sf::Context>(sf::ContextSettings(), width, height)), + context(nullptr), textureBuffer(nullptr), desired_size(width, height) { - ContextScope context_scope(context.get()); + //ContextScope context_scope(context.get()); texture.setSmooth(true); // mpv_create requires LC_NUMERIC to be set to "C" for some reason, see mpv_create documentation |