diff options
Diffstat (limited to 'src/VideoPlayer.cpp')
-rw-r--r-- | src/VideoPlayer.cpp | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/src/VideoPlayer.cpp b/src/VideoPlayer.cpp index 5369a07..1049bcf 100644 --- a/src/VideoPlayer.cpp +++ b/src/VideoPlayer.cpp @@ -48,6 +48,7 @@ namespace QuickMedia { static const double READ_TIMEOUT_SEC = 3.0; static std::string media_chapters_to_ffmetadata_chapters(std::vector<MediaChapter> chapters) { + // Required for mpv to display chapters correctly std::sort(chapters.begin(), chapters.end(), [](const MediaChapter &a, const MediaChapter &b) { return a.start_seconds < b.start_seconds; }); @@ -460,7 +461,7 @@ namespace QuickMedia { return Error::OK; } - VideoPlayer::Error VideoPlayer::get_time_in_file(double *result) { + VideoPlayer::Error VideoPlayer::get_time_in_file(double *result_seconds) { Json::Value json_root(Json::objectValue); json_root["command"] = "time-pos"; @@ -469,11 +470,24 @@ namespace QuickMedia { if(err != Error::OK) return err; - *result = time_pos_json.asDouble(); + *result_seconds = time_pos_json.asDouble(); return err; } - VideoPlayer::Error VideoPlayer::get_duration_in_file(double *result) { + VideoPlayer::Error VideoPlayer::set_time_in_file(double time_in_seconds) { + Json::Value json_root(Json::objectValue); + json_root["command"] = "set-time-pos"; + json_root["data"] = time_in_seconds; + + Json::Value time_pos_json; + Error err = send_command(json_root, &time_pos_json, Json::ValueType::realValue); + if(err != Error::OK) + return err; + + return err; + } + + VideoPlayer::Error VideoPlayer::get_duration(double *result) { Json::Value json_root(Json::objectValue); json_root["command"] = "duration"; |