blob: 94378e4cb26e8f759a1921e012ee4c81907e82ee (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
;;; mpv.el --- Open MPV through Emacs! -*- lexical-binding: t; -*-
;; Copyright (C) 2024 Aryadev Chavali
;; Author: Aryadev Chavali <aryadev@aryadevchavali.com>
;; Keywords: convenience
;; This program is free software; you can redistribute it and/or
;; modify it under the terms of the GNU General Public License Version
;; 2 as published by the Free Software Foundation.
;; 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:
;;
;;; Code:
(autoload #'ffap-guesser "ffap")
(autoload #'ansi-color-for-comint-mode-on "ansi-color")
(autoload #'comint-mode "comint")
(autoload #'comint-output-filter "comint")
(defvar mpv-args "-v --profile=fast --hwdec=auto-copy"
"General arguments for mpv binary.")
(defun mpv-start-process (url)
(message "[mpv]: Starting mpv on `%s'" url)
(with-current-buffer (get-buffer-create "*mpv*")
(ansi-color-for-comint-mode-on)
(comint-mode))
(set-process-filter (start-process-shell-command
"mpv" "*mpv*"
(concat "mpv " mpv-args " \"" url "\""))
#'comint-output-filter))
(defun mpv-open-video (&optional arg)
(interactive)
(let ((url (if (stringp arg)
arg
(completing-read "Enter URL: " nil nil t (ffap-guesser) mpv--history))))
(mpv-start-process url)
(switch-to-buffer "*mpv*")))
(provide 'mpv)
;;; mpv.el ends here
|