aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--TODO3
-rw-r--r--include/Body.hpp1
-rw-r--r--include/QuickMedia.hpp2
-rw-r--r--src/Body.cpp15
-rw-r--r--src/QuickMedia.cpp50
-rw-r--r--src/VideoPlayer.cpp1
6 files changed, 52 insertions, 20 deletions
diff --git a/TODO b/TODO
index e847fc1..68b0fc5 100644
--- a/TODO
+++ b/TODO
@@ -168,4 +168,5 @@ Load the next page in chapter list when reaching the bottom (when going to previ
Loading image background should be rounded.
//Workaround mpv issue where video is frozen after seeking (with and without cache enabled, but more often with cache enabled). This happens because of audio. Reloading audio fixes this but audio will then be gone.
Better deal with reading from file errors. This could happen when reading a file while its being modified. See read_file_as_json.
-Fix youtube comments. \ No newline at end of file
+Fix youtube comments.
+Somehow fix youtube throttling speed limit to as low as 20-80kb which is fixed with a refresh. This should be detected automatically somehow. \ No newline at end of file
diff --git a/include/Body.hpp b/include/Body.hpp
index 8fffcb0..841ba5a 100644
--- a/include/Body.hpp
+++ b/include/Body.hpp
@@ -203,6 +203,7 @@ namespace QuickMedia {
// Select next item, ignoring invisible items. Returns true if the item was changed or if the item scrolled. This can be used to check if the bottom was hit when wrap_around is set to false
bool select_next_item(bool scroll_page_if_large_item = false, bool ignore_columns = false);
void set_selected_item(int item, bool reset_prev_selected_item = true);
+ void set_selected_item(BodyItem *body_item);
void reset_prev_selected_item();
// Returns -1 if item can't be found
diff --git a/include/QuickMedia.hpp b/include/QuickMedia.hpp
index 70d3637..a1656aa 100644
--- a/include/QuickMedia.hpp
+++ b/include/QuickMedia.hpp
@@ -116,7 +116,7 @@ namespace QuickMedia {
bool page_loop(std::vector<Tab> &tabs, int start_tab_index = 0, PageLoopSubmitHandler after_submit_handler = nullptr);
void video_page_download_video(const std::string &url, bool use_youtube_dl, sf::WindowHandle video_player_window = None);
bool video_download_if_non_streamable(std::string &video_url, std::string &audio_url, bool &is_audio_only, bool &has_embedded_audio, PageType previous_page);
- void video_content_page(Page *parent_page, VideoPage *video_page, std::string video_title, bool download_if_streaming_fails, BodyItems &next_play_items, int play_index, int *parent_body_page = nullptr, const std::string &parent_page_search = "");
+ void video_content_page(Page *parent_page, VideoPage *video_page, std::string video_title, bool download_if_streaming_fails, Body *parent_body, BodyItems &next_play_items, int play_index, int *parent_body_page = nullptr, const std::string &parent_page_search = "");
// Returns -1 to go to previous chapter, 0 to stay on same chapter and 1 to go to next chapter
int image_page(MangaImagesPage *images_page, Body *chapters_body);
void image_continuous_page(MangaImagesPage *images_page);
diff --git a/src/Body.cpp b/src/Body.cpp
index 2df514b..ba99c62 100644
--- a/src/Body.cpp
+++ b/src/Body.cpp
@@ -285,6 +285,20 @@ namespace QuickMedia {
//page_scroll = 0.0f;
}
+ void Body::set_selected_item(BodyItem *body_item) {
+ if(!body_item)
+ return;
+
+ for(size_t i = 0; i < items.size(); ++i) {
+ if(items[i].get() == body_item) {
+ selected_item = i;
+ break;
+ }
+ }
+
+ clamp_selection();
+ }
+
void Body::reset_prev_selected_item() {
prev_selected_item = selected_item;
}
@@ -1605,6 +1619,7 @@ namespace QuickMedia {
void Body::filter_search_fuzzy(const std::string &text) {
current_filter = text;
+ items_dirty = DirtyState::FALSE;
if(text.empty()) {
for(auto &item : items) {
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp
index 5316d3f..bf6cf7e 100644
--- a/src/QuickMedia.cpp
+++ b/src/QuickMedia.cpp
@@ -1197,7 +1197,7 @@ namespace QuickMedia {
current_page = PageType::VIDEO_CONTENT;
auto youtube_video_page = std::make_unique<YoutubeVideoPage>(this, youtube_url);
BodyItems body_items;
- video_content_page(nullptr, youtube_video_page.get(), "", false, body_items, 0);
+ video_content_page(nullptr, youtube_video_page.get(), "", false, nullptr, body_items, 0);
}
} else if(strcmp(plugin_name, "pornhub") == 0) {
auto search_page = std::make_unique<MediaGenericSearchPage>(this, "https://www.pornhub.com/", sf::Vector2i(320/1.5f, 180/1.5f));
@@ -1791,7 +1791,7 @@ namespace QuickMedia {
page_stack.push(current_page);
current_page = PageType::VIDEO_CONTENT;
int selected_index = tabs[selected_tab].body->get_selected_item();
- video_content_page(tabs[selected_tab].page.get(), static_cast<VideoPage*>(new_tabs[0].page.get()), "", false, tabs[selected_tab].body->items, selected_index, &tab_associated_data[selected_tab].fetched_page, tab_associated_data[selected_tab].update_search_text);
+ video_content_page(tabs[selected_tab].page.get(), static_cast<VideoPage*>(new_tabs[0].page.get()), "", false, tabs[selected_tab].body.get(), tabs[selected_tab].body->items, selected_index, &tab_associated_data[selected_tab].fetched_page, tab_associated_data[selected_tab].update_search_text);
} else if(new_tabs.size() == 1 && new_tabs[0].page->get_type() == PageTypez::CHAT) {
MatrixChatPage *tmp_matrix_chat_page = static_cast<MatrixChatPage*>(new_tabs[0].page.get());
MatrixRoomsPage *rooms_page = tmp_matrix_chat_page->rooms_page;
@@ -2084,6 +2084,7 @@ namespace QuickMedia {
if(associated_data.search_text_updated && associated_data.fetch_status == FetchStatus::NONE && !associated_data.fetching_next_page_running) {
std::string update_search_text = associated_data.update_search_text;
associated_data.search_text_updated = false;
+ tabs[i].body->clear_items();
associated_data.fetch_status = FetchStatus::LOADING;
associated_data.fetch_type = FetchType::SEARCH;
associated_data.search_result_text.setString("Searching...");
@@ -2455,7 +2456,7 @@ namespace QuickMedia {
#define CLEANMASK(mask) ((mask) & (ShiftMask|ControlMask|Mod1Mask|Mod4Mask|Mod5Mask))
- void Program::video_content_page(Page *parent_page, VideoPage *video_page, std::string video_title, bool download_if_streaming_fails, BodyItems &next_play_items, int play_index, int *parent_body_page, const std::string &parent_page_search) {
+ void Program::video_content_page(Page *parent_page, VideoPage *video_page, std::string video_title, bool download_if_streaming_fails, Body *parent_body, BodyItems &next_play_items, int play_index, int *parent_body_page, const std::string &parent_page_search) {
PageType previous_page = pop_page_stack();
bool video_loaded = false;
@@ -2467,8 +2468,11 @@ namespace QuickMedia {
video_player.reset();
BodyItems related_videos;
- if(video_page->autoplay_next_item() && play_index + 1 >= 0 && play_index + 1 < (int)next_play_items.size())
+ bool move_in_parent = false;
+ if(video_page->autoplay_next_item() && play_index + 1 >= 0 && play_index + 1 < (int)next_play_items.size()) {
related_videos.insert(related_videos.end(), next_play_items.begin() + play_index + 1, next_play_items.end());
+ move_in_parent = true;
+ }
sf::WindowHandle video_player_window = None;
auto on_window_create = [this, &video_player_window](sf::WindowHandle _video_player_window) mutable {
@@ -2849,9 +2853,13 @@ namespace QuickMedia {
}
// Find video that hasn't been played before in this video session
- auto find_next_video = [this, &related_videos, &video_page, &new_video_url]() {
+ auto find_next_video = [this, parent_body, move_in_parent, &related_videos, &video_page, &new_video_url]() {
for(auto it = related_videos.begin(), end = related_videos.end(); it != end; ++it) {
if(!(*it)->url.empty() && watched_videos.find((*it)->url) == watched_videos.end() && !video_page->video_should_be_skipped((*it)->url)) {
+ if(parent_body && move_in_parent) {
+ parent_body->filter_search_fuzzy("");
+ parent_body->set_selected_item(it->get());
+ }
new_video_url = (*it)->url;
related_videos.erase(it);
break;
@@ -2875,6 +2883,7 @@ namespace QuickMedia {
size_t num_new_messages = new_body_items.size();
if(num_new_messages > 0) {
next_play_items.insert(next_play_items.end(), new_body_items.begin(), new_body_items.end());
+ if(parent_body) parent_body->items_set_dirty();
(*parent_body_page)++;
related_videos = std::move(new_body_items);
find_next_video();
@@ -3661,8 +3670,8 @@ namespace QuickMedia {
sf::Vector2f body_size;
sf::Event event;
- std::stack<int> comment_navigation_stack;
- std::stack<int> comment_page_scroll_stack;
+ std::deque<int> comment_navigation_stack;
+ std::deque<int> comment_page_scroll_stack;
while (current_page == PageType::IMAGE_BOARD_THREAD && window.isOpen()) {
while (window.pollEvent(event)) {
@@ -3705,8 +3714,13 @@ namespace QuickMedia {
watched_videos.clear();
thread_page->set_url(selected_item->url);
BodyItems next_items;
+ int prev_selected = thread_body->get_selected_item();
// TODO: Use real title
- video_content_page(thread_page, thread_page, "", true, thread_body->items, thread_body->get_selected_item());
+ video_content_page(thread_page, thread_page, "", true, thread_body, thread_body->items, thread_body->get_selected_item());
+ if(thread_body->get_selected_item() != prev_selected) {
+ comment_navigation_stack.clear();
+ comment_page_scroll_stack.clear();
+ }
redraw = true;
} else {
BodyItem *selected_item = thread_body->get_selected();
@@ -3777,7 +3791,7 @@ namespace QuickMedia {
}
BodyItem *selected_item = thread_body->get_selected();
- if(event.key.code == sf::Keyboard::Enter && selected_item && (comment_navigation_stack.empty() || thread_body->get_selected_item() != comment_navigation_stack.top()) && (!selected_item->replies_to.empty() || !selected_item->replies.empty())) {
+ if(event.key.code == sf::Keyboard::Enter && selected_item && (comment_navigation_stack.empty() || thread_body->get_selected_item() != comment_navigation_stack.back()) && (!selected_item->replies_to.empty() || !selected_item->replies.empty())) {
for(auto &body_item : thread_body->items) {
body_item->visible = false;
}
@@ -3788,15 +3802,15 @@ namespace QuickMedia {
for(size_t reply_index : selected_item->replies) {
thread_body->items[reply_index]->visible = true;
}
- comment_navigation_stack.push(thread_body->get_selected_item());
- comment_page_scroll_stack.push(thread_body->get_page_scroll());
+ comment_navigation_stack.push_back(thread_body->get_selected_item());
+ comment_page_scroll_stack.push_back(thread_body->get_page_scroll());
//thread_body->clamp_selection();
thread_body->set_page_scroll(0.0f);
} else if(event.key.code == sf::Keyboard::BackSpace && !comment_navigation_stack.empty()) {
- size_t previous_selected = comment_navigation_stack.top();
- float previous_page_scroll = comment_page_scroll_stack.top();
- comment_navigation_stack.pop();
- comment_page_scroll_stack.pop();
+ size_t previous_selected = comment_navigation_stack.back();
+ float previous_page_scroll = comment_page_scroll_stack.back();
+ comment_navigation_stack.pop_back();
+ comment_page_scroll_stack.pop_back();
if(comment_navigation_stack.empty()) {
for(auto &body_item : thread_body->items) {
body_item->visible = true;
@@ -3808,7 +3822,7 @@ namespace QuickMedia {
body_item->visible = false;
}
thread_body->set_selected_item(previous_selected);
- selected_item = thread_body->items[comment_navigation_stack.top()].get();
+ selected_item = thread_body->items[comment_navigation_stack.back()].get();
selected_item->visible = true;
for(size_t reply_to_index : selected_item->replies_to) {
thread_body->items[reply_to_index]->visible = true;
@@ -5165,7 +5179,7 @@ namespace QuickMedia {
current_page = PageType::VIDEO_CONTENT;
auto youtube_video_page = std::make_unique<YoutubeVideoPage>(this, url);
// TODO: Use real title
- video_content_page(matrix_chat_page, youtube_video_page.get(), "", false, tabs[MESSAGES_TAB_INDEX].body->items, tabs[MESSAGES_TAB_INDEX].body->get_selected_item());
+ video_content_page(matrix_chat_page, youtube_video_page.get(), "", false, nullptr, tabs[MESSAGES_TAB_INDEX].body->items, tabs[MESSAGES_TAB_INDEX].body->get_selected_item());
redraw = true;
avatar_applied = false;
} else {
@@ -5243,7 +5257,7 @@ namespace QuickMedia {
no_video = is_audio;
video_page->set_url(selected->url);
BodyItems next_items;
- video_content_page(matrix_chat_page, video_page.get(), selected_item_message->body, message_type == MessageType::VIDEO || message_type == MessageType::AUDIO, next_items, 0);
+ video_content_page(matrix_chat_page, video_page.get(), selected_item_message->body, message_type == MessageType::VIDEO || message_type == MessageType::AUDIO, nullptr, next_items, 0);
no_video = prev_no_video;
redraw = true;
avatar_applied = false;
diff --git a/src/VideoPlayer.cpp b/src/VideoPlayer.cpp
index 47544e9..9e17bda 100644
--- a/src/VideoPlayer.cpp
+++ b/src/VideoPlayer.cpp
@@ -106,6 +106,7 @@ namespace QuickMedia {
"--hr-seek=yes",
//"--cache=no",
"--force-seekable=yes",
+ "--image-display-duration=5",
"--cache-pause=yes",
input_conf.c_str(),
wid_arg.c_str()