aboutsummaryrefslogtreecommitdiff
path: root/src/QuickMedia.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/QuickMedia.cpp')
-rw-r--r--src/QuickMedia.cpp19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp
index 65a5387..5dd1ebb 100644
--- a/src/QuickMedia.cpp
+++ b/src/QuickMedia.cpp
@@ -2363,6 +2363,19 @@ namespace QuickMedia {
download_async_gui(url, file_manager_start_dir.string(), true, audio_only);
}
+ static std::string youtube_url_extract_timestamp(const std::string &url) {
+ size_t timestamp_start = url.find("t=");
+ if(timestamp_start == std::string::npos)
+ return "";
+
+ timestamp_start += 2;
+ size_t timestamp_end = url.find('&');
+ if(timestamp_end == std::string::npos)
+ timestamp_end = url.size();
+
+ return url.substr(timestamp_start, timestamp_end - timestamp_start);
+ }
+
#define CLEANMASK(mask) ((mask) & (ShiftMask|ControlMask|Mod1Mask|Mod4Mask|Mod5Mask))
void Program::video_content_page(Page *parent_page, VideoPage *video_page, std::string video_title, bool download_if_streaming_fails, BodyItems &next_play_items, int play_index, int *parent_body_page, const std::string &parent_page_search) {
@@ -2497,12 +2510,16 @@ namespace QuickMedia {
}
}
}
+
+ std::string start_time;
+ if(is_youtube)
+ start_time = youtube_url_extract_timestamp(video_page->get_url());
time_watched_timer.restart();
watched_videos.insert(video_page->get_url());
video_player = std::make_unique<VideoPlayer>(is_audio_only, use_system_mpv_config, resume_video, is_matrix && !is_youtube, video_event_callback, on_window_create, resources_root, largest_monitor_height);
- VideoPlayer::Error err = video_player->load_video(video_url.c_str(), audio_url.c_str(), window.getSystemHandle(), plugin_name, video_title);
+ VideoPlayer::Error err = video_player->load_video(video_url.c_str(), audio_url.c_str(), window.getSystemHandle(), plugin_name, video_title, start_time);
if(err != VideoPlayer::Error::OK) {
std::string err_msg = "Failed to play url: ";
err_msg += video_page->get_url();