Last active
July 2, 2026 11:08
-
-
Save MasWag/1092e0082c296b6709be6ae5b2094f36 to your computer and use it in GitHub Desktop.
library to use MPV player as a backend of EMMS on macOS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ;;; emms-player-mpv-macos.el --- library to use MPV player as a backend of EMMS on macOS -*- lexical-binding: t; -*- | |
| ;; Copyright (C) 2026 Masaki Waga | |
| ;; Authors: Masaki Waga | |
| ;; Keywords: multimedia, mpv, emms | |
| ;; This program 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. | |
| ;; | |
| ;; This program 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 this program. If not, see <https://www.gnu.org/licenses/>. | |
| ;;; Commentary: | |
| ;; emms-player-mpv-macos.el is a library to use the MPV player as a | |
| ;; backend for EMMS on macOS. In particular, the default volume | |
| ;; control of EMMS may not work properly with the MPV player on macOS. | |
| ;;; Code: | |
| (require 'emms-volume) | |
| (require 'emms-player-mpv) | |
| ;;;###autoload | |
| (defun emms-player-mpv-macos-show-volume () | |
| "Show the current volume of the MPV player." | |
| (interactive) | |
| (emms-player-mpv-cmd | |
| '(get_property volume) | |
| (lambda (volume err) | |
| (if err | |
| (message "Native volume error: %s" err) | |
| (message "Native volume is %s%%" volume))))) | |
| ;;;###autoload | |
| (defun emms-player-mpv-macos-set-volume (volume) | |
| "Set the volume of the MPV player to VOLUME." | |
| (emms-player-mpv-cmd | |
| `(set_property volume ,volume) | |
| (lambda (_data err) | |
| (if err | |
| (message "Native volume error: %s" err) | |
| (message "Native volume set to %s%%" volume))))) | |
| ;;;###autoload | |
| (defun emms-player-mpv-macos-change (amount) | |
| "Change the volume of the MPV player by AMOUNT." | |
| (emms-player-mpv-cmd | |
| `(add volume ,amount) | |
| (lambda (_data err) | |
| (if err | |
| (message "Native volume error: %s" err) | |
| (emms-player-mpv-cmd | |
| '(get_property volume) | |
| (lambda (volume err) | |
| (if err | |
| (message "Native volume error: %s" err) | |
| (message "Native volume is %s%%" volume)))))))) | |
| ;;;###autoload | |
| (defun emms-player-mpv-macos-setup () | |
| "Use mpv's internal volume control for EMMS." | |
| (interactive) | |
| (setq emms-volume-change-function #'emms-player-mpv-macos-change)) | |
| (provide 'emms-player-mpv-macos) | |
| ;;; emms-player-mpv-macos.el ends here |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment