aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/QuickMedia.cpp17
-rw-r--r--src/VideoPlayer.cpp6
2 files changed, 11 insertions, 12 deletions
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp
index 6447029..480be75 100644
--- a/src/QuickMedia.cpp
+++ b/src/QuickMedia.cpp
@@ -1631,6 +1631,8 @@ namespace QuickMedia {
sf::Clock time_watched_timer;
bool added_recommendations = false;
bool video_loaded = false;
+ const bool is_youtube = strcmp(plugin_name, "youtube") == 0;
+ const bool is_matrix = strcmp(plugin_name, "matrix") == 0;
PageType previous_page = pop_page_stack();
@@ -1696,13 +1698,11 @@ namespace QuickMedia {
XSync(disp, False);
};
- 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](bool resume_video) mutable {
+ auto load_video_error_check = [this, &related_videos, &channel_url, &video_url, &video_title, &video_player, previous_page, &time_watched_timer, &video_loaded, &added_recommendations, video_page, &video_event_callback, &on_window_create, &video_player_window, is_matrix](bool resume_video) mutable {
time_watched_timer.restart();
video_loaded = false;
- end_of_file = false;
video_player_window = None;
added_recommendations = false;
watched_videos.insert(video_url);
@@ -1714,7 +1714,7 @@ namespace QuickMedia {
video_url_converted = video_url;
}
- video_player = std::make_unique<VideoPlayer>(use_tor, no_video, use_system_mpv_config, resume_video, video_event_callback, on_window_create, resources_root);
+ video_player = std::make_unique<VideoPlayer>(use_tor, no_video, use_system_mpv_config, resume_video, is_matrix, 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: ";
@@ -1762,7 +1762,7 @@ namespace QuickMedia {
}
};
- video_event_callback = [this, &video_player, &end_of_file, &time_watched_timer, &video_loaded](const char *event_name) mutable {
+ video_event_callback = [&video_player, &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)
@@ -1779,9 +1779,6 @@ namespace QuickMedia {
video_loaded = true;
time_watched_timer.restart();
}
- } else if(strcmp(event_name, "end-file") == 0 && current_page == PageType::VIDEO_CONTENT) {
- video_loaded = false;
- end_of_file = true;
}
fprintf(stderr, "event name: %s\n", event_name);
@@ -1795,8 +1792,6 @@ namespace QuickMedia {
bool cursor_visible = true;
sf::Clock cursor_hide_timer;
- bool is_youtube = strcmp(plugin_name, "youtube") == 0;
-
auto save_video_url_to_clipboard = [&video_url_is_local, &video_url, &video_player_window, &video_player]() {
if(!video_player_window || video_url_is_local)
return;
@@ -1907,7 +1902,7 @@ namespace QuickMedia {
show_notification("QuickMedia", "Failed to connect to mpv ipc after 10 seconds", Urgency::CRITICAL);
current_page = previous_page;
break;
- } else if(update_err == VideoPlayer::Error::EXITED && video_player->exit_status == 0) {
+ } else if(update_err == VideoPlayer::Error::EXITED && video_player->exit_status == 0 && !is_matrix) {
std::string new_video_url;
std::string new_video_title;
// Find video that hasn't been played before in this video session
diff --git a/src/VideoPlayer.cpp b/src/VideoPlayer.cpp
index 0510a4c..c6f5a36 100644
--- a/src/VideoPlayer.cpp
+++ b/src/VideoPlayer.cpp
@@ -18,12 +18,13 @@ const int MAX_RETRIES_CONNECT = 20;
const int READ_TIMEOUT_MS = 200;
namespace QuickMedia {
- VideoPlayer::VideoPlayer(bool use_tor, bool no_video, bool use_system_mpv_config, bool resume_playback, EventCallbackFunc _event_callback, VideoPlayerWindowCreateCallback _window_create_callback, const std::string &resource_root) :
+ VideoPlayer::VideoPlayer(bool use_tor, bool no_video, bool use_system_mpv_config, bool resume_playback, bool keep_open, EventCallbackFunc _event_callback, VideoPlayerWindowCreateCallback _window_create_callback, const std::string &resource_root) :
exit_status(0),
use_tor(use_tor),
no_video(no_video),
use_system_mpv_config(use_system_mpv_config),
resume_playback(resume_playback),
+ keep_open(keep_open),
video_process_id(-1),
ipc_socket(-1),
connected_to_ipc(false),
@@ -104,6 +105,9 @@ namespace QuickMedia {
wid_arg.c_str()
});
+ if(keep_open)
+ args.push_back("--keep-open=yes");
+
if(!resume_playback)
args.push_back("--no-resume-playback");