Closed sachac closed 3 years ago
- subed/subed.el: Bind C-c C-w (mnemonic: web?) to subed-mpv-play-video-from-url.
Looks like you ended up with C-u C-u, which I like better anyway. The function also uses "url", not "web".
As it turns out, MPV does the Right Thing when given a .webm URL
Fun fact: If you have youtube-dl installed, mpv uses it and you can play youtube and lots of other video hosting) URLs.
I don't like all the duplicated code. Everything in
(let ((filepath (expand-file-name file)))
...)
is identical except for one debug message and a variable name. That's 12 non-trivial lines that have to be maintained twice.
I would add a private function that is called by subed-mpv-play-video-from-url and subed-mpv-find-video. Something like this (untested):
(defun subed-mpv--play (video)
(when (subed-mpv--server-started-p)
(subed-mpv-kill))
(when (apply #'subed-mpv--server-start subed-mpv-arguments)
(subed-debug "Playing video: %s" video)
(subed-mpv--client-connect subed-mpv--retry-delays)
(subed-mpv--client-send `(loadfile ,video replace))
;; mpv won't add the subtitles if the file doesn't exist yet, so we add it
;; via after-save-hook.
(if (file-exists-p (buffer-file-name))
(subed-mpv-add-subtitles (buffer-file-name))
(add-hook 'after-save-hook #'subed-mpv--add-subtitle-after-first-save :append :local))
(subed-mpv--client-send `(observe_property 1 time-pos))
(subed-mpv-playback-speed subed-playback-speed-while-not-typing)))
Great idea! How about this one?
Looks great and seems to work.
As it turns out, MPV does the Right Thing when given a .webm URL, so people can use a URL as a video reference and all the usual synchronization just works.