aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2023-11-29 14:38:41 +0100
committerdec05eba <dec05eba@protonmail.com>2023-11-29 14:38:41 +0100
commitc71b04dad549ceaa9e06d524bc2ca11034dd1dbf (patch)
tree7833862713d9644131d20e4173cec3efb8eab29e
parent815e955c332fcc92a47fc9cc2903a02e13d85c1c (diff)
Playlist skip unplayable items
-rw-r--r--src/QuickMedia.cpp40
1 files changed, 28 insertions, 12 deletions
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);
}
}