aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/emms.texinfo7
-rw-r--r--lisp/emms-player-mpv.el127
-rw-r--r--lisp/emms-setup.el2
3 files changed, 133 insertions, 3 deletions
diff --git a/doc/emms.texinfo b/doc/emms.texinfo
index e5b5db9..215d282 100644
--- a/doc/emms.texinfo
+++ b/doc/emms.texinfo
@@ -195,8 +195,9 @@ to your @file{.emacs}.
The function @code{emms-default-players} in the last line sets up the
list of default players. The list contains lightweight specialized
players like ogg123 or mpg321 and we-play-everything-players such as
-mplayer, vlc, etc.. To be sure that emms can play all your music you
-should check that your preferred players are installed on the machine.
+mplayer, mpv, vlc, etc.. To be sure that emms can play all your music
+you should check that your preferred players are installed on the
+machine.
More detail about setting up Emms can be found in the setup chapter,
@xref{Setup}.
@@ -2342,7 +2343,7 @@ more information about Emms setup levels see @xref{Setup}.
`emms-stream-info' calls a backend program to query the stream for
information. The preferred program needs to be specified by setting
-the variable @var{emms-stream-info-backend} either `mplayer' or
+the variable @var{emms-stream-info-backend} either `mplayer', `mpv' or
`vlc'. For instance:
@lisp
diff --git a/lisp/emms-player-mpv.el b/lisp/emms-player-mpv.el
new file mode 100644
index 0000000..6d67f8c
--- /dev/null
+++ b/lisp/emms-player-mpv.el
@@ -0,0 +1,127 @@
+;;; emms-player-mpv.el --- mpv support for EMMS
+
+;; Copyright (C) 2013-2018 ZHANG Weiyi
+;; Copyright (C) 2014 Alex Kost
+;; Copyright (C) 2018 stardiviner <numbchild@gmail.com>
+;; Copyright (C) 2018 Free Software Foundation, Inc.
+
+;; Authors: ZHANG Weiyi <dochang@gmail.com>,
+;; Alex Kost <alezost@gmail.com>,
+;; stardiviner <numbchild@gmail.com>
+
+;; This file is part of EMMS.
+
+;; EMMS is free software; you can redistribute it and/or
+;; modify it under the terms of the GNU General Public License
+;; as published by the Free Software Foundation; either version 3
+;; of the License, or (at your option) any later version.
+
+;; EMMS is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with EMMS; if not, write to the Free Software Foundation,
+;; Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+
+;;; Commentary:
+
+;; This provides a player that uses mpv. It supports pause and
+;; seeking. See mpv manual for more.
+;;
+;; To load subtitles automatically,
+;; put "`sub-auto=fuzzy"` in the mpv's config file.
+;;
+;; To disable the cover display when playing music, use the following:
+;; (add-to-list 'emms-player-mpv-parameters "--no-audio-display")
+;; Alternatively you can also add "audio-display=no" to mpv's config file.
+;;
+;; This file is based on `emms-player-mplayer.el'. It was originally hosted at
+;; https://github.com/dochang/emms-player-mpv.
+
+;;; Code:
+
+(require 'emms-compat)
+(require 'emms-player-simple)
+
+(defcustom emms-player-mpv-input-file
+ (expand-file-name (locate-user-emacs-file "emms-mpv-input-file"))
+ "The file to send command to mpv."
+ :type 'file
+ :group 'emms)
+
+(define-emms-simple-player mpv '(file url streamlist playlist)
+ (concat "\\`\\(https?\\|mms\\)://\\|"
+ (emms-player-simple-regexp
+ "ogg" "mp3" "wav" "mpg" "mpeg" "wmv" "wma"
+ "mov" "avi" "divx" "ogm" "ogv" "asf" "mkv"
+ "rm" "rmvb" "mp4" "flac" "vob" "m4a" "ape"
+ "flv" "webm" "m4b" "m4p" "m4v" "m4r" "3gp"
+ "aac"))
+ "mpv" "--quiet" "--really-quiet")
+
+(defadvice emms-player-mpv-start (around append-arguments activate)
+ (unless (file-exists-p emms-player-mpv-input-file)
+ (call-process "mkfifo" nil nil nil emms-player-mpv-input-file))
+ (let* ((input-file (format "--input-file=%s" emms-player-mpv-input-file))
+ (track-arg (let* ((track (ad-get-arg 0))
+ (track-type (emms-track-get track 'type))
+ (track-name (emms-track-name track)))
+ (if (memq track-type '(streamlist playlist))
+ (format "--playlist=%s" track-name)
+ track-name)))
+ (process (apply 'start-process
+ emms-player-simple-process-name
+ nil
+ emms-player-mpv-command-name
+ (append emms-player-mpv-parameters
+ (list input-file track-arg)))))
+ (set-process-sentinel process 'emms-player-simple-sentinel))
+ (emms-player-started emms-player-mpv))
+
+(emms-player-set emms-player-mpv
+ 'pause
+ 'emms-player-mpv-pause)
+
+(emms-player-set emms-player-mpv
+ 'resume
+ 'emms-player-mpv-resume)
+
+(emms-player-set emms-player-mpv
+ 'seek
+ 'emms-player-mpv-seek)
+
+(emms-player-set emms-player-mpv
+ 'seek-to
+ 'emms-player-mpv-seek-to)
+
+(defun emms-player-mpv--format-command (fmt &rest args)
+ "Generate shell command to control mpv."
+ (let ((mpv-cmd (apply 'format fmt args)))
+ (format "echo %s > %s"
+ (shell-quote-argument mpv-cmd)
+ (shell-quote-argument emms-player-mpv-input-file))))
+
+(defun emms-player-mpv-pause ()
+ "Depends on mpv's --input-file option."
+ (let ((cmd (emms-player-mpv--format-command "set pause yes")))
+ (call-process-shell-command cmd nil nil nil)))
+
+(defun emms-player-mpv-resume ()
+ "Depends on mpv's --input-file option."
+ (let ((cmd (emms-player-mpv--format-command "set pause no")))
+ (call-process-shell-command cmd nil nil nil)))
+
+(defun emms-player-mpv-seek (sec)
+ "Depends on mpv's --input-file option."
+ (let ((cmd (emms-player-mpv--format-command "seek %d" sec)))
+ (call-process-shell-command cmd nil nil nil)))
+
+(defun emms-player-mpv-seek-to (sec)
+ "Depends on mpv's --input-file option."
+ (let ((cmd (emms-player-mpv--format-command "seek %d absolute" sec)))
+ (call-process-shell-command cmd nil nil nil)))
+
+(provide 'emms-player-mpv)
+;;; emms-player-mpv.el ends here
diff --git a/lisp/emms-setup.el b/lisp/emms-setup.el
index 47260b5..fde9212 100644
--- a/lisp/emms-setup.el
+++ b/lisp/emms-setup.el
@@ -52,6 +52,7 @@
emms-player-ogg123
emms-player-mplayer-playlist
emms-player-mplayer
+ emms-player-mpv
emms-player-vlc
emms-player-vlc-playlist)
"*Default list of players for emms-setup."
@@ -66,6 +67,7 @@ Invisible playlists and all the basics for playing media."
(require 'emms-source-playlist)
(require 'emms-player-simple)
(require 'emms-player-mplayer)
+ (require 'emms-player-mpv)
(require 'emms-player-vlc))
;;;###autoload