From 93b89cf4fce6b48ba8e26e9e907cbbb9e9632cf1 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sat, 13 Jun 2020 14:11:12 +0200 Subject: Fix related videos sometimes being skipped --- src/QuickMedia.cpp | 12 ++++++++---- src/VideoPlayer.cpp | 8 ++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp index 6cd92b7..8299423 100644 --- a/src/QuickMedia.cpp +++ b/src/QuickMedia.cpp @@ -659,19 +659,23 @@ namespace QuickMedia { current_page = previous_page; } }; - - video_player = std::make_unique(current_plugin->use_tor, [this, &video_player, &seekable, &load_video_error_check, previous_page](const char *event_name) { + + bool has_video_started = true; + video_player = std::make_unique(current_plugin->use_tor, [this, &video_player, &seekable, &load_video_error_check, previous_page, &has_video_started](const char *event_name) mutable { bool end_of_file = false; if(strcmp(event_name, "pause") == 0) { - double time_remaining = 0.0; + double time_remaining = 9999.0; if(video_player->get_time_remaining(&time_remaining) == VideoPlayer::Error::OK && time_remaining <= 1.0) end_of_file = true; } else if(strcmp(event_name, "playback-restart") == 0) { video_player->set_paused(false); video_player->is_seekable(&seekable); + } else if(strcmp(event_name, "start-file") == 0) { + has_video_started = true; } - if(end_of_file) { + if(end_of_file && has_video_started) { + has_video_started = false; std::string new_video_url; BodyItems related_media = current_plugin->get_related_media(content_url); // Find video that hasn't been played before in this video session diff --git a/src/VideoPlayer.cpp b/src/VideoPlayer.cpp index b88789d..9845442 100644 --- a/src/VideoPlayer.cpp +++ b/src/VideoPlayer.cpp @@ -12,8 +12,8 @@ #include #include -const int RETRY_TIME_MS = 1000; -const int MAX_RETRIES_CONNECT = 5; +const int RETRY_TIME_MS = 500; +const int MAX_RETRIES_CONNECT = 10; const int READ_TIMEOUT_MS = 200; namespace QuickMedia { @@ -136,9 +136,9 @@ namespace QuickMedia { } VideoPlayer::Error VideoPlayer::update() { - int max_retries_find_window = 10; + int max_retries_find_window = 20; if(use_tor) - max_retries_find_window = 30; + max_retries_find_window = 60; if(ipc_socket == -1) return Error::INIT_FAILED; -- cgit v1.2.3