Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add option 'nyan-music-player' along with support for mpv #42

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions nyan-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,25 @@
(setq nyan-animation-timer nil)
(setq nyan-animate-nyancat nil)))

;; mplayer needs to be installed for that
(defcustom nyan-music-player "mplayer"
"Change a music player for NyanCat."
:type '(choice (const "mplayer")
(const "mpv"))
:group 'nyan)

(defvar nyan-music-process nil)

(defun nyan--start-music-command ()
(cond ((string-equal nyan-music-player "mplayer")
(concat "mplayer " +nyan-music+ " -loop 0"))
((string-equal nyan-music-player "mpv")
(concat "mpv " +nyan-music+ " -loop 0"))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this work? Locally I use:

(start-process-shell-command "nyan-music"
                             "nyan-music"
                             (concat "mpv --no-video --loop=inf " nyan-music))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or for a copy paste solution if/until this gets merged:

(use-package nyan-mode
  :config
  (defun my/nyan-start-music ()
    (unless nyan-music-process
      (setq nyan-music-process
	    (start-process-shell-command
	     "nyan-music"
             "nyan-music"
             (concat "mpv " nyan-music " --loop=inf")))))
  (advice-add 'nyan-start-music :override 'my/nyan-start-music)
  (nyan-mode 1)
  (unless (nyan--is-animating-p) (nyan-start-animation))
  (nyan-start-music))

(t (error "Unknown music player"))))

(defun nyan-start-music ()
(interactive)
(unless nyan-music-process
(setq nyan-music-process (start-process-shell-command "nyan-music" "nyan-music" (concat "mplayer " +nyan-music+ " -loop 0")))))
(setq nyan-music-process (start-process-shell-command "nyan-music" "nyan-music" (nyan--start-music-command)))))

(defun nyan-stop-music ()
(interactive)
Expand Down