diff options
author | dec05eba <dec05eba@protonmail.com> | 2020-09-27 08:01:54 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2020-09-27 08:01:54 +0200 |
commit | 3eccedbcea41accb708e8cd8e7f956d06c70f4a3 (patch) | |
tree | fcd71299e5dffb0ad4033665fe8b7f3aafba43ce /src/VideoPlayer.cpp | |
parent | 6a82b66921c24d5310479df33abcf977ab231772 (diff) |
Save currently playing video url to clipboard with ctrl+s
Diffstat (limited to 'src/VideoPlayer.cpp')
-rw-r--r-- | src/VideoPlayer.cpp | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/VideoPlayer.cpp b/src/VideoPlayer.cpp index 0811c74..0ad4152 100644 --- a/src/VideoPlayer.cpp +++ b/src/VideoPlayer.cpp @@ -18,7 +18,7 @@ const int MAX_RETRIES_CONNECT = 20; const int READ_TIMEOUT_MS = 200; namespace QuickMedia { - VideoPlayer::VideoPlayer(bool use_tor, bool use_system_mpv_config, EventCallbackFunc _event_callback, VideoPlayerWindowCreateCallback _window_create_callback) : + VideoPlayer::VideoPlayer(bool use_tor, bool use_system_mpv_config, EventCallbackFunc _event_callback, VideoPlayerWindowCreateCallback _window_create_callback, const std::string &resource_root) : exit_status(0), use_tor(use_tor), use_system_mpv_config(use_system_mpv_config), @@ -35,7 +35,8 @@ namespace QuickMedia { request_id(1), expected_request_id(0), request_response_data(Json::nullValue), - response_data_status(ResponseDataStatus::NONE) + response_data_status(ResponseDataStatus::NONE), + resource_root(resource_root) { display = XOpenDisplay(NULL); if (!display) @@ -76,6 +77,8 @@ namespace QuickMedia { std::string wid_arg = "--wid="; wid_arg += parent_window_str; + std::string input_conf = "--input-conf=" + resource_root + "input.conf"; + // TODO: Resume playback if the last video played matches the first video played next time QuickMedia is launched args.insert(args.end(), { "mpv", "--keep-open=yes", input_ipc_server_arg.c_str(), @@ -83,6 +86,7 @@ namespace QuickMedia { "--cursor-autohide=no", /* "--no-input-default-bindings", "--input-vo-keyboard=no", "--no-input-cursor", */ "--no-terminal", "--ytdl-raw-options=sub-lang=\"en,eng,enUS,en-US\",write-sub=", + input_conf.c_str(), wid_arg.c_str() }); @@ -290,6 +294,16 @@ namespace QuickMedia { return err; } + VideoPlayer::Error VideoPlayer::get_time_in_file(double *result) { + Json::Value time_pos_json; + Error err = get_property("time-pos", &time_pos_json, Json::realValue); + if(err != Error::OK) + return err; + + *result = time_pos_json.asDouble(); + return err; + } + VideoPlayer::Error VideoPlayer::get_time_remaining(double *result) { Json::Value time_remaining_json; Error err = get_property("time-remaining", &time_remaining_json, Json::realValue); |