From 43e7de19358f730ee18d690a993e97a5195b80c9 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Thu, 29 Jul 2021 05:16:57 +0200 Subject: Faster video loading/error when not using xxx plugin (disable ytdl) --- src/VideoPlayer.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/VideoPlayer.cpp') diff --git a/src/VideoPlayer.cpp b/src/VideoPlayer.cpp index 98d215d..7f01912 100644 --- a/src/VideoPlayer.cpp +++ b/src/VideoPlayer.cpp @@ -70,6 +70,7 @@ namespace QuickMedia { no_video(no_video), use_system_mpv_config(use_system_mpv_config), keep_open(keep_open), + use_youtube_dl(true), video_process_id(-1), connected_to_ipc(false), connect_tries(0), @@ -115,7 +116,7 @@ namespace QuickMedia { remove(tmp_chapters_filepath); } - VideoPlayer::Error VideoPlayer::launch_video_process(const char *path, const char *audio_path, sf::WindowHandle _parent_window, bool is_youtube, const std::string &title, const std::string &start_time) { + VideoPlayer::Error VideoPlayer::launch_video_process(const char *path, const char *audio_path, sf::WindowHandle _parent_window, const std::string &title, const std::string &start_time) { parent_window = _parent_window; if(!tmpnam(ipc_server_path)) { @@ -166,7 +167,7 @@ namespace QuickMedia { else ytdl_format = "--ytdl-format=bestvideo[height<=?" + std::to_string(monitor_height) + "]+bestaudio/best"; - if(is_youtube) + if(!use_youtube_dl) args.push_back("--no-ytdl"); else args.push_back(ytdl_format.c_str()); @@ -232,17 +233,18 @@ namespace QuickMedia { return Error::OK; } - VideoPlayer::Error VideoPlayer::load_video(const char *path, const char *audio_path, sf::WindowHandle _parent_window, bool is_youtube, const std::string &title, const std::string &start_time, const std::vector &chapters) { + VideoPlayer::Error VideoPlayer::load_video(const char *path, const char *audio_path, sf::WindowHandle _parent_window, bool use_youtube_dl, const std::string &title, const std::string &start_time, const std::vector &chapters) { // This check is to make sure we dont change window that the video belongs to. This is not a usecase we will have so // no need to support it for now at least. assert(parent_window == 0 || parent_window == _parent_window); assert(path); + this->use_youtube_dl = use_youtube_dl; if(!create_tmp_file_with_chapters_data(tmp_chapters_filepath, chapters)) fprintf(stderr, "Warning: failed to create chapters file. Chapters will not be displayed\n"); fprintf(stderr, "Playing video: %s, audio: %s\n", path ? path : "", audio_path ? audio_path : ""); if(video_process_id == -1) - return launch_video_process(path, audio_path, _parent_window, is_youtube, title, start_time); + return launch_video_process(path, audio_path, _parent_window, title, start_time); // TODO: When these are used, add audio_path, title and start_time. Also handle is_youtube Json::Value command_data(Json::arrayValue); -- cgit v1.2.3