[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/subed e71a64b 339/389: Refactor common code into subed-mpv
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/subed e71a64b 339/389: Refactor common code into subed-mpv-play-video |
Date: |
Fri, 3 Dec 2021 11:00:53 -0500 (EST) |
branch: elpa/subed
commit e71a64b76642f67766f7cec609ab54ad633a8d6f
Author: Sacha Chua <sacha@sachachua.com>
Commit: Sacha Chua <sacha@sachachua.com>
Refactor common code into subed-mpv-play-video
* subed/subed-mpv.el (subed-mpv--play): New function.
(subed-mpv-play-video-from-url): Call subed-mpv--play.
(subed-mpv-find-video): Call subed-mpv--play.
---
subed/subed-mpv.el | 32 +++++++++++++-------------------
1 file changed, 13 insertions(+), 19 deletions(-)
diff --git a/subed/subed-mpv.el b/subed/subed-mpv.el
index cf3a92f..bd706bc 100644
--- a/subed/subed-mpv.el
+++ b/subed/subed-mpv.el
@@ -335,15 +335,14 @@ See \"List of events\" in mpv(1)."
(or (file-directory-p filepath)
(member (file-name-extension filename) subed-video-extensions)))))
-(defun subed-mpv-play-video-from-url (url)
- "Open video file from URL in mpv."
- (interactive "MURL: ")
+(defun subed-mpv--play (video)
+ "Open VIDEO and play it in MPV."
(when (subed-mpv--server-started-p)
(subed-mpv-kill))
(when (apply #'subed-mpv--server-start subed-mpv-arguments)
- (subed-debug "Opening video from URL: %s" url)
+ (subed-debug "Opening video: %s" video)
(subed-mpv--client-connect subed-mpv--retry-delays)
- (subed-mpv--client-send `(loadfile ,url replace))
+ (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))
@@ -352,26 +351,21 @@ See \"List of events\" in mpv(1)."
(subed-mpv--client-send `(observe_property 1 time-pos))
(subed-mpv-playback-speed subed-playback-speed-while-not-typing)))
+(defun subed-mpv-play-video-from-url (url)
+ "Open video file from URL in mpv.
+See the MPV manual for a list of supported URL types. If you have
+youtube-dl installed, MPV can open videos from a variety of
+hosting providers."
+ (interactive "MURL: ")
+ (subed-mpv--play url))
+
(defun subed-mpv-find-video (file)
"Open video file FILE in mpv.
Video files are expected to have any of the extensions listed in
`subed-video-extensions'."
(interactive (list (read-file-name "Find video: " nil nil t nil
#'subed-mpv--is-video-file-p)))
- (let ((filepath (expand-file-name file)))
- (when (subed-mpv--server-started-p)
- (subed-mpv-kill))
- (when (apply #'subed-mpv--server-start subed-mpv-arguments)
- (subed-debug "Opening video file: %s" filepath)
- (subed-mpv--client-connect subed-mpv--retry-delays)
- (subed-mpv--client-send `(loadfile ,filepath 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))))
+ (subed-mpv--play (expand-file-name file)))
(defun subed-mpv--add-subtitle-after-first-save ()
"Tell mpv to load subtitles from function `buffer-file-name'.
- [nongnu] elpa/subed 473fbc2 319/389: subed-srt--subtitle-text: Improve docstring, (continued)
- [nongnu] elpa/subed 473fbc2 319/389: subed-srt--subtitle-text: Improve docstring, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 05ba952 320/389: Only add subtitles file if subed-subtitle-id returns non-nil, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed ea11119 321/389: Inform compiler about unused variables to prevent warnings, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed e8a68c2 322/389: subed-srt--msecs-to-timestamp: Explain save-match-data, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 5c39418 323/389: Copy subed-srt--msecs-to-timestamp to subed-common.el, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed ecfec2b 325/389: Move debugging functions to subed-debug.el, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed f69f769 327/389: Set subed-mode-map in subed.el, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed d110f79 329/389: Stop disabling point-to-player sync on file-loaded event, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed dd4dc8c 332/389: Automatically disable point-to-player sync while looping, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 5957cbe 333/389: Set default subed-loop-seconds-after/before to 1, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed e71a64b 339/389: Refactor common code into subed-mpv-play-video,
ELPA Syncer <=
- [nongnu] elpa/subed daaf480 340/389: subed-vtt: Fix navigation code, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 9642945 346/389: Further fixes to let tests pass, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 0968590 344/389: Fix separator search in subed-srt--validate, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 9e661cc 351/389: New command subed-split-subtitle splits at point with MPV timestamp, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed a63c362 252/389: More work on README, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed b5da89e 254/389: Move defgroup to the top, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 7d5c543 255/389: Add function: subed-srt--init, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 3036e7c 256/389: Remove stale comment, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed df51c44 258/389: Rename test file for common functions, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed c1e05c6 259/389: Remove empty line, ELPA Syncer, 2021/12/03