aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2022-03-13 08:05:42 +0100
committerdec05eba <dec05eba@protonmail.com>2022-03-13 08:05:42 +0100
commit0b1f7936b0d52ad39016c9a7ad5320474034d500 (patch)
treeeb260be04d7bfdb866bb066d8419f9a3f0245ea0 /src
parent05a5413108e33ebbca699303baf1fe13a91eff2a (diff)
Only update watch progress if the video successfully loads
Diffstat (limited to 'src')
-rw-r--r--src/QuickMedia.cpp18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp
index 24c2a87..e6e8e68 100644
--- a/src/QuickMedia.cpp
+++ b/src/QuickMedia.cpp
@@ -3062,6 +3062,8 @@ namespace QuickMedia {
bool video_loaded = false;
double video_time_pos = 0.0; // Time in media in seconds. Updates every 5 seconds and when starting to watch the video and when seeking.
double video_duration = 0.0; // Time in seconds. 0 if unknown
+ bool successfully_fetched_video_duration = false;
+ bool successfully_fetched_time_pos = false;
bool update_time_pos = false;
bool update_duration = false;
bool update_window_focus = false;
@@ -3123,7 +3125,10 @@ namespace QuickMedia {
video_player.reset();
channel_url.clear();
video_loaded = false;
+ successfully_fetched_video_duration = false;
+ successfully_fetched_time_pos = false;
video_player_window = None;
+ video_duration = 0.0;
bool is_audio_only = no_video;
const int video_max_height = video_get_max_height();
@@ -3144,6 +3149,9 @@ namespace QuickMedia {
if(video_page->load(new_title, channel_url, video_duration, media_chapters, err_str) != PluginResult::OK)
return false;
+ if(video_duration > 0.001)
+ successfully_fetched_video_duration = true;
+
std::string ext;
if(!no_video)
video_url = video_page->get_video_url(video_max_height, has_embedded_audio, ext);
@@ -3458,7 +3466,8 @@ namespace QuickMedia {
show_video_player_window(video_player_window);
show_notification("QuickMedia", "Failed to get related pages", Urgency::CRITICAL);
} else if(related_pages_result == TaskResult::TRUE && !related_pages.empty()) {
- video_page->set_watch_progress(video_time_pos, video_duration);
+ if(successfully_fetched_time_pos && successfully_fetched_video_duration)
+ video_page->set_watch_progress(video_time_pos, video_duration);
bool page_changed = false;
double resume_start_time = 0.0;
@@ -3635,11 +3644,13 @@ namespace QuickMedia {
if(update_time_pos) {
update_time_pos = false;
- video_player->get_time_in_file(&video_time_pos);
+ if(video_player->get_time_in_file(&video_time_pos) == VideoPlayer::Error::OK)
+ successfully_fetched_time_pos = true;
}
if(update_duration) {
update_duration = false;
+ successfully_fetched_video_duration = true;
double file_duration = 0.0;
video_player->get_duration_in_file(&file_duration);
video_duration = std::max(video_duration, file_duration);
@@ -3669,7 +3680,8 @@ namespace QuickMedia {
window_size.x = window_size_u.x;
window_size.y = window_size_u.y;
- video_page->set_watch_progress(video_time_pos, video_duration);
+ if(successfully_fetched_time_pos && successfully_fetched_video_duration)
+ video_page->set_watch_progress(video_time_pos, video_duration);
}
void Program::select_episode(BodyItem *item, bool start_from_beginning) {