aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/QuickMedia.cpp21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp
index 1251663..47e2530 100644
--- a/src/QuickMedia.cpp
+++ b/src/QuickMedia.cpp
@@ -2404,8 +2404,9 @@ namespace QuickMedia {
std::string channel_url;
AsyncTask<BodyItems> video_tasks;
std::function<void(const char*)> video_event_callback;
+ bool go_to_previous_page = false;
- auto load_video_error_check = [this, &video_title, &video_tasks, &video_player, &channel_url, previous_page, &time_watched_timer, &video_loaded, video_page, &video_event_callback, &on_window_create, &video_player_window, is_youtube, is_matrix, download_if_streaming_fails](bool resume_video) mutable {
+ auto load_video_error_check = [this, &video_title, &video_tasks, &video_player, &channel_url, previous_page, &go_to_previous_page, &time_watched_timer, &video_loaded, video_page, &video_event_callback, &on_window_create, &video_player_window, is_youtube, is_matrix, download_if_streaming_fails](bool resume_video) mutable {
video_player.reset();
channel_url.clear();
video_loaded = false;
@@ -2421,10 +2422,12 @@ namespace QuickMedia {
if(load_result == TaskResult::CANCEL) {
current_page = previous_page;
+ go_to_previous_page = true;
return;
} else if(load_result == TaskResult::FALSE) {
show_notification("QuickMedia", "Failed to load media", Urgency::CRITICAL);
current_page = previous_page;
+ go_to_previous_page = true;
return;
}
@@ -2474,6 +2477,7 @@ namespace QuickMedia {
if(create_directory_recursive(video_cache_dir) != 0) {
show_notification("QuickMedia", "Failed to create video cache directory", Urgency::CRITICAL);
current_page = previous_page;
+ go_to_previous_page = true;
return;
}
@@ -2497,15 +2501,18 @@ namespace QuickMedia {
case TaskResult::FALSE: {
show_notification("QuickMedia", "Failed to download " + video_url, Urgency::CRITICAL);
current_page = previous_page;
+ go_to_previous_page = true;
return;
}
case TaskResult::CANCEL: {
current_page = previous_page;
+ go_to_previous_page = true;
return;
}
}
} else if(video_is_not_streamble_result == TaskResult::CANCEL) {
current_page = previous_page;
+ go_to_previous_page = true;
return;
}
}
@@ -2525,6 +2532,7 @@ namespace QuickMedia {
err_msg += video_page->get_url();
show_notification("QuickMedia", err_msg.c_str(), Urgency::CRITICAL);
current_page = previous_page;
+ go_to_previous_page = true;
} else {
if(video_page->autoplay_next_item())
return;
@@ -2620,7 +2628,7 @@ namespace QuickMedia {
}
};
- while (current_page == PageType::VIDEO_CONTENT && window.isOpen()) {
+ while (current_page == PageType::VIDEO_CONTENT && window.isOpen() && !go_to_previous_page) {
while (window.pollEvent(event)) {
if(event.type == sf::Event::Resized) {
window_size.x = event.size.width;
@@ -2633,6 +2641,7 @@ namespace QuickMedia {
window_set_fullscreen(disp, window.getSystemHandle(), WindowFullscreenState::UNSET);
} else {
current_page = previous_page;
+ go_to_previous_page = true;
}
} else if(event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::F && event.key.control) {
window_set_fullscreen(disp, window.getSystemHandle(), WindowFullscreenState::TOGGLE);
@@ -2653,6 +2662,7 @@ namespace QuickMedia {
window_set_fullscreen(disp, window.getSystemHandle(), WindowFullscreenState::UNSET);
} else {
current_page = previous_page;
+ go_to_previous_page = true;
break;
}
} else if(pressed_keysym == XK_f && pressing_ctrl) {
@@ -2762,6 +2772,7 @@ namespace QuickMedia {
if(update_err == VideoPlayer::Error::FAIL_TO_CONNECT_TIMEOUT) {
show_notification("QuickMedia", "Failed to connect to mpv ipc after 10 seconds", Urgency::CRITICAL);
current_page = previous_page;
+ go_to_previous_page = true;
break;
} else if(update_err == VideoPlayer::Error::EXITED && video_player->exit_status == 0 && (!is_matrix || is_youtube)) {
std::string new_video_url;
@@ -2782,6 +2793,7 @@ namespace QuickMedia {
if(task_result == TaskResult::CANCEL || task_result == TaskResult::FALSE) {
current_page = previous_page;
+ go_to_previous_page = true;
return;
}
}
@@ -2820,6 +2832,7 @@ namespace QuickMedia {
if(load_next_page_result == TaskResult::CANCEL) {
current_page = previous_page;
+ go_to_previous_page = true;
continue;
}
}
@@ -2828,6 +2841,7 @@ namespace QuickMedia {
if(new_video_url.empty()) {
show_notification("QuickMedia", "No more related videos to play");
current_page = previous_page;
+ go_to_previous_page = true;
break;
}
@@ -2838,10 +2852,12 @@ namespace QuickMedia {
if(get_playable_url_result == TaskResult::CANCEL) {
current_page = previous_page;
+ go_to_previous_page = true;
return;
} else if(get_playable_url_result == TaskResult::FALSE) {
show_notification("QuickMedia", "Failed to get playable url", Urgency::CRITICAL);
current_page = previous_page;
+ go_to_previous_page = true;
return;
}
@@ -2849,6 +2865,7 @@ namespace QuickMedia {
} 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;
+ go_to_previous_page = true;
break;
}