diff options
author | dec05eba <dec05eba@protonmail.com> | 2020-06-13 14:11:12 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2020-06-13 14:11:12 +0200 |
commit | 93b89cf4fce6b48ba8e26e9e907cbbb9e9632cf1 (patch) | |
tree | 8cb4ec37edd085cd2fa96750e14c1a6ae42a05f2 | |
parent | 31239d029e0449ca18b258aeacb46b45ee54aab0 (diff) |
Fix related videos sometimes being skipped
-rw-r--r-- | src/QuickMedia.cpp | 12 | ||||
-rw-r--r-- | 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<VideoPlayer>(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<VideoPlayer>(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 <fcntl.h> #include <signal.h> -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; |