diff options
-rw-r--r-- | include/mpv.hpp | 2 | ||||
-rw-r--r-- | src/main.cpp | 6 | ||||
-rw-r--r-- | src/mpv.cpp | 12 |
3 files changed, 15 insertions, 5 deletions
diff --git a/include/mpv.hpp b/include/mpv.hpp index 6f3b559..b4e22b3 100644 --- a/include/mpv.hpp +++ b/include/mpv.hpp @@ -11,7 +11,7 @@ public: Mpv() = default; ~Mpv(); - bool create(); + bool create(bool use_system_mpv_config); bool destroy(); bool load_file(const char *path); diff --git a/src/main.cpp b/src/main.cpp index f611dc0..016a392 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -300,6 +300,7 @@ private: // X compositor bool cursor_wrap = true; bool free_camera = false; bool reduce_flicker = false; + bool use_system_mpv_config = false; double reduce_flicker_counter = 0.0; GLuint arrow_image_texture_id = 0; @@ -419,6 +420,7 @@ static void usage() { fprintf(stderr, " --free-camera If this option is set, then the camera wont follow your position\n"); fprintf(stderr, " --follow-focused If this option is set, then the selected window will be the focused window. vr-video-player will automatically update when the focused window changes. Either this option, --video or window_id should be used\n"); fprintf(stderr, " --video <video> Select the video to play (using mpv). Either this option, --follow-focused or window_id should be used\n"); + fprintf(stderr, " --use-system-mpv-config Use system (~/.config/mpv/mpv.conf) mpv config. Disabled by default\n"); fprintf(stderr, " window_id The X11 window id of the window to view in vr. Either this option, --follow-focused or --video should be used\n"); fprintf(stderr, "\n"); fprintf(stderr, "EXAMPLES\n"); @@ -565,6 +567,8 @@ CMainApplication::CMainApplication( int argc, char *argv[] ) } mpv_file = argv[i + 1]; ++i; + } else if(strcmp(argv[i], "--use-system-mpv-config") == 0) { + use_system_mpv_config = true; } else if(strcmp(argv[i], "--free-camera") == 0) { free_camera = true; } else if(strcmp(argv[i], "--reduce-flicker") == 0) { @@ -838,7 +842,7 @@ bool CMainApplication::BInit() if(mpv_file) { mpv_thread = std::thread([&]{ set_current_context(m_pMpvContext); - if(!mpv.create()) + if(!mpv.create(use_system_mpv_config)) return; mpv.load_file(mpv_file); diff --git a/src/mpv.cpp b/src/mpv.cpp index 4d5e391..164021e 100644 --- a/src/mpv.cpp +++ b/src/mpv.cpp @@ -38,7 +38,7 @@ static bool exec_program_daemonized(const char **args) { } static void show_notification(const char *title, const char *msg, const char *urgency) { - const char *args[] = { "notify-send", "-t", "10000", "-u", urgency, "--", title, msg, NULL }; + const char *args[] = { "notify-send", "-a", "vr-video-player", "-t", "10000", "-u", urgency, "--", title, msg, NULL }; exec_program_daemonized(args); } @@ -64,7 +64,7 @@ Mpv::~Mpv() { destroy(); } -bool Mpv::create() { +bool Mpv::create(bool use_system_mpv_config) { if(created) return false; @@ -74,6 +74,11 @@ bool Mpv::create() { return false; } + if(use_system_mpv_config) { + mpv_set_option_string(mpv, "config", "yes"); + mpv_set_option_string(mpv, "load-scripts", "yes"); + } + if(mpv_initialize(mpv) < 0) { fprintf(stderr, "Error: mpv_initialize failed\n"); mpv_destroy(mpv); @@ -195,7 +200,8 @@ void Mpv::on_event(SDL_Event &event, bool *render_update, int64_t *width, int64_ mpv_event_end_file *msg = (mpv_event_end_file*)mp_event->data; if(msg->reason == MPV_END_FILE_REASON_ERROR) { show_notification("vr video player mpv video error", mpv_error_string(msg->error), "critical"); - exit(6); + if(quit) + *quit = true; } if(msg->reason == MPV_END_FILE_REASON_EOF) { show_notification("vr video player", "the video ended", "low"); |