From c71b04dad549ceaa9e06d524bc2ca11034dd1dbf Mon Sep 17 00:00:00 2001 From: dec05eba Date: Wed, 29 Nov 2023 14:38:41 +0100 Subject: Playlist skip unplayable items --- src/QuickMedia.cpp | 40 ++++++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp index 4e0367a..edf7851 100644 --- a/src/QuickMedia.cpp +++ b/src/QuickMedia.cpp @@ -3610,17 +3610,35 @@ namespace QuickMedia { }; auto play_next_video = [&]() -> bool { - if(parent_body->select_next_item(false, true)) { - play_video(parent_body->get_selected()->url); + while(true) { + if(!parent_body->select_next_item(false, true)) { + if(load_next_page() == 0) { + return false; + } else { + continue; + } + } + + BodyItem *selected = parent_body->get_selected(); + if(selected->url.empty() || video_page->video_should_be_skipped(selected->url)) + continue; + + play_video(selected->url); return true; - } else { - if(load_next_page() == 0) { + } + }; + + auto play_previous_video = [&]() -> bool { + while(true) { + if(!parent_body->select_previous_item(false, true)) return false; - } else { - parent_body->select_next_item(false, true); - play_video(parent_body->get_selected()->url); - return true; - } + + BodyItem *selected = parent_body->get_selected(); + if(selected->url.empty() || video_page->video_should_be_skipped(selected->url)) + continue; + + play_video(selected->url); + return true; } }; @@ -3713,9 +3731,7 @@ namespace QuickMedia { if(!play_next_video()) show_notification("QuickMedia", "You have reached the last video in the playlist", Urgency::LOW); } else { - if(parent_body->select_previous_item(false, true)) { - play_video(parent_body->get_selected()->url); - } else { + if(!play_previous_video()) { show_notification("QuickMedia", "You have reached the first video in the playlist", Urgency::LOW); } } -- cgit v1.2.3