diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/QuickMedia.cpp | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp index 4b19722..6447029 100644 --- a/src/QuickMedia.cpp +++ b/src/QuickMedia.cpp @@ -1696,11 +1696,10 @@ namespace QuickMedia { XSync(disp, False); }; - bool has_video_started = true; bool end_of_file = false; std::function<void(const char*)> video_event_callback; - auto load_video_error_check = [this, &related_videos, &channel_url, &video_url, &video_title, &video_player, previous_page, &time_watched_timer, &video_loaded, &end_of_file, &added_recommendations, video_page, &video_event_callback, &on_window_create, &video_player_window]() mutable { + auto load_video_error_check = [this, &related_videos, &channel_url, &video_url, &video_title, &video_player, previous_page, &time_watched_timer, &video_loaded, &end_of_file, &added_recommendations, video_page, &video_event_callback, &on_window_create, &video_player_window](bool resume_video) mutable { time_watched_timer.restart(); video_loaded = false; end_of_file = false; @@ -1715,7 +1714,7 @@ namespace QuickMedia { video_url_converted = video_url; } - video_player = std::make_unique<VideoPlayer>(use_tor, no_video, use_system_mpv_config, false, video_event_callback, on_window_create, resources_root); + video_player = std::make_unique<VideoPlayer>(use_tor, no_video, use_system_mpv_config, resume_video, video_event_callback, on_window_create, resources_root); VideoPlayer::Error err = video_player->load_video(video_url_converted.c_str(), window.getSystemHandle(), plugin_name); if(err != VideoPlayer::Error::OK) { std::string err_msg = "Failed to play url: "; @@ -1763,7 +1762,7 @@ namespace QuickMedia { } }; - video_event_callback = [this, &related_videos, &video_url, &video_title, &video_player, &load_video_error_check, previous_page, &has_video_started, &end_of_file, &time_watched_timer, &video_loaded](const char *event_name) mutable { + video_event_callback = [this, &video_player, &end_of_file, &time_watched_timer, &video_loaded](const char *event_name) mutable { if(strcmp(event_name, "pause") == 0) { //double time_remaining = 9999.0; //if(video_player->get_time_remaining(&time_remaining) == VideoPlayer::Error::OK && time_remaining <= 1.0) @@ -1771,7 +1770,6 @@ namespace QuickMedia { } else if(strcmp(event_name, "playback-restart") == 0) { //video_player->set_paused(false); } else if(strcmp(event_name, "file-loaded") == 0) { - has_video_started = true; time_watched_timer.restart(); if(!video_loaded) video_player->set_property("no-resume-playback", true); @@ -1789,7 +1787,7 @@ namespace QuickMedia { fprintf(stderr, "event name: %s\n", event_name); }; - load_video_error_check(); + load_video_error_check(false); sf::Event event; @@ -1884,10 +1882,8 @@ namespace QuickMedia { if(page_changed) { current_page = PageType::VIDEO_CONTENT; - video_player_window = None; - has_video_started = true; //video_player = std::make_unique<VideoPlayer>(use_tor, no_video, use_system_mpv_config, true, video_event_callback, on_window_create, resources_root); - load_video_error_check(); + load_video_error_check(true); } else { XMapWindow(disp, video_player_window); XSync(disp, False); @@ -1912,7 +1908,6 @@ namespace QuickMedia { current_page = previous_page; break; } else if(update_err == VideoPlayer::Error::EXITED && video_player->exit_status == 0) { - has_video_started = false; std::string new_video_url; std::string new_video_title; // Find video that hasn't been played before in this video session @@ -1934,7 +1929,7 @@ namespace QuickMedia { video_url = std::move(new_video_url); video_title = std::move(new_video_title); - load_video_error_check(); + load_video_error_check(false); } else if(update_err != VideoPlayer::Error::OK) { show_notification("QuickMedia", "Failed to play the video (error code " + std::to_string((int)update_err) + ")", Urgency::CRITICAL); current_page = previous_page; |