emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/mpv deb643d0a7 1/3: Add mpv-play-url command


From: ELPA Syncer
Subject: [nongnu] elpa/mpv deb643d0a7 1/3: Add mpv-play-url command
Date: Mon, 1 Aug 2022 10:58:59 -0400 (EDT)

branch: elpa/mpv
commit deb643d0a7c87fa9a61c47b1b8f95fd35117e045
Author: Johann Klähn <johann@jklaehn.de>
Commit: Johann Klähn <johann@jklaehn.de>

    Add mpv-play-url command
    
    Closes #14, closes #27.
    
    Co-authored-by: Detlev V <detvdael.services@protonmail.com>
---
 mpv.el | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/mpv.el b/mpv.el
index c8eff4d293..1c5fd46b06 100644
--- a/mpv.el
+++ b/mpv.el
@@ -451,6 +451,10 @@ If the entry is LOOPING, `mpv-loop-indicator' is appended."
       formatted-entries
     (user-error "No entries in playlist")))
 
+(defun mpv--url-p (url)
+  "Return if URL is an HTTP(S) URL."
+  (member (url-type (url-generic-parse-url url)) '("http" "https")))
+
 ;;;###autoload
 (defun mpv-play (path)
   "Start an mpv process playing the file at PATH.
@@ -461,6 +465,17 @@ See `mpv-start' if you need to pass further arguments and
   (interactive "fFile: ")
   (mpv-start (expand-file-name path)))
 
+;;;###autoload
+(defun mpv-play-url (url)
+  "Start an mpv process playing the video stream at URL.
+
+See `mpv-start' if you need to pass further arguments and
+`mpv-default-options' for default options."
+  (interactive "sURL: ")
+  (unless (mpv--url-p url)
+    (user-error "Invalid argument: `%s' (must be a valid URL)" url))
+  (mpv-start url))
+
 ;;;###autoload
 (defun mpv-playlist-append (url &rest args)
   "Append URL to the current mpv playlist.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]