From f8e9b2e6099dd569e971b32c3a733ea8e5e0952d Mon Sep 17 00:00:00 2001 From: jao Date: Sun, 31 Jul 2022 03:58:06 +0100 Subject: jao-mpc: playing http radio streams --- custom/jao-custom-completion.el | 2 +- custom/jao-custom-gnus.el | 2 +- init.el | 13 +++++-------- lib/media/jao-mpc.el | 29 +++++++++++++++++++++++++++-- 4 files changed, 34 insertions(+), 12 deletions(-) diff --git a/custom/jao-custom-completion.el b/custom/jao-custom-completion.el index 0e36fcc..c5c3e52 100644 --- a/custom/jao-custom-completion.el +++ b/custom/jao-custom-completion.el @@ -403,7 +403,7 @@ (define-key embark-url-map (kbd "f") #'browse-url-firefox) (define-key embark-url-map (kbd "x") #'jao-rss-subscribe) (define-key embark-url-map (kbd "m") 'jao-browse-with-external-browser) -(define-key embark-url-map (kbd "p") 'jao-browse-add-url-to-mpc) +(define-key embark-url-map (kbd "p") 'jao-mpc-add-or-play-url) ;;;; video url targets (defvar jao-embark-targets-video-sites diff --git a/custom/jao-custom-gnus.el b/custom/jao-custom-gnus.el index 8f76563..d8a0b6e 100644 --- a/custom/jao-custom-gnus.el +++ b/custom/jao-custom-gnus.el @@ -704,7 +704,7 @@ (when (search-forward "Enclosure:") (forward-char 2) (when-let ((url (thing-at-point-url-at-point))) - (jao-browse-add-url-to-mpc url)))))) + (jao-mpc-add-or-play-url url)))))) ;;; Add-ons ;;;; gnus-icalendar diff --git a/init.el b/init.el index dbcf67a..c77496a 100644 --- a/init.el +++ b/init.el @@ -1590,12 +1590,8 @@ (defvar jao-browse--sound-rx (format "^https?://.*/.*\\.%s" (regexp-opt '("mp4" "mp3" "flv")))) -(defun jao-browse-add-url-to-mpc (url &rest _) - "Add the given URL to mpc's playing list, or just play it." - (let ((p (yes-or-no-p (format "Play %s right now?" url)))) - (when p (jao-mpc-clear)) - (jao-mpc-add-url url) - (if p (jao-mpc-play) (message "%s added to mpc queue" url)))) +(defun jao-browse-play-sound-url (url &rest _) + (jao-mpc-add-or-play-url url)) (defun jao-browse-url-browse (&rest args) (apply jao-browse-url-function args)) @@ -1608,7 +1604,7 @@ ("^file://?" . jao--find-file-other-window) (,jao-browse--external-regexp . ,jao-browse-url-external-function) ("^https?://.*\\.gotomeeting\\.com\\.*" . browse-url-chrome) - (,jao-browse--sound-rx . jao-browse-add-url-to-mpc) + (,jao-browse--sound-rx . jao-browse-play-sound-url) (,(jao-wget--regexp) . jao-download) (jao-video--url-p . jao-maybe-view-video) ("." . jao-browse-url-browse))) @@ -3097,7 +3093,8 @@ ["Seek and search" ("f" "seek fwd" jao-player-seek-10 :transient t) ("F" "seek bwd" jao-player-seek--10 :transient t) - ("a" "search album" jao-mpc-search-and-select-album)] + ("a" "search album" jao-mpc-search-and-select-album) + ("S" "play stream" jao-mpc-play-stream)] ["Browse" ("b" "browse" jao-player-browse) ("l" "show play list" jao-player-list) diff --git a/lib/media/jao-mpc.el b/lib/media/jao-mpc.el index a86795b..5633648 100644 --- a/lib/media/jao-mpc.el +++ b/lib/media/jao-mpc.el @@ -95,8 +95,8 @@ (format "%s%s %s%s%s%s" ;;  (jao--put-face (if (zerop no) "" (format "%02d/%s " no len)) 'jao-themes-f02) - (jao--put-face title 'jao-themes-f00) - (jao--put-face artist 'jao-themes-f01) + (jao--put-face (or title "") 'jao-themes-f00) + (jao--put-face (or artist "") 'jao-themes-f01) (jao--put-face (if composer (format " [%s]" composer) "") 'jao-themes-f01) (jao--put-face (if album (format " (%s)" album) "") 'jao-themes-f11) @@ -235,6 +235,31 @@ (interactive "sURL: ") (jao-mpc--cmd (format "add %s" url))) +;;;###autoload +(defun jao-mpc-add-or-play-url (url &optional play) + "Add the given URL to mpc's playing list, or just play it." + (let ((p (or play (yes-or-no-p (format "Play %s right now?" url))))) + (when p (jao-mpc-clear)) + (jao-mpc-add-url url) + (if p (jao-mpc-play) (message "%s added to mpc queue" url)))) + +(defvar jao-mpc-stream-urls + '(("classic fm" . "http://media-ice.musicradio.com:80/ClassicFMMP3") + ("wcpe" . "http://audio-mp3.ibiblio.org:8000/wcpe.mp3") + ("cinemix" . "http://94.23.51.96:8000") + ("bbc gold" . "http://media-ice.musicradio.com:80/GoldMP3") + ("irish gold" . "http://icecast2.rte.ie/gold"))) + +;; other cinemix: +;; http://209.9.238.4:6022 http://209.9.238.4:6046 + +;;;###autoload +(defun jao-mpc-play-stream () + "Select a predefined stream URL and add or play it in mpc." + (interactive) + (let ((s (completing-read "Stream: " jao-mpc-stream-urls))) + (jao-mpc-add-or-play-url (cdr (assoc s jao-mpc-stream-urls)) t))) + ;;;###autoload (defun jao-mpc-show-albums (&optional port) "Show album list." -- cgit v1.2.3