feat: add new command for play file by mpv directly
This commit is contained in:
3 files changed
+37
-1
No files matched your search
@@ -111,7 +111,9 @@
|
|||||||
(setq dired-recursive-deletes 'always)
|
(setq dired-recursive-deletes 'always)
|
||||||
|
|
||||||
;; don't make too many dired buffer
|
;; don't make too many dired buffer
|
||||||
(put 'dired-find-alternate-file 'disabled nil))
|
(put 'dired-find-alternate-file 'disabled nil)
|
||||||
|
|
||||||
|
(define-key dired-mode-map (kbd "b") #'creature/mpv))
|
||||||
|
|
||||||
(add-hook 'display-fill-column-indicator-mode-hook
|
(add-hook 'display-fill-column-indicator-mode-hook
|
||||||
(lambda ()
|
(lambda ()
|
||||||
|
|||||||
@@ -44,6 +44,39 @@
|
|||||||
(buffer-string)))
|
(buffer-string)))
|
||||||
(t (concat "/sudo:root@localhost:" fname))))))
|
(t (concat "/sudo:root@localhost:" fname))))))
|
||||||
|
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
;; mpv ;;
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
(defun creature/is-bd-dir (dir)
|
||||||
|
(let ((index-file (file-name-concat dir "BDMV" "index.bdmv"))
|
||||||
|
(stream-dir (file-name-concat dir "BDMV" "STREAM"))
|
||||||
|
(playlist-dir (file-name-concat dir "BDMV" "PLAYLIST")))
|
||||||
|
(and (file-exists-p index-file)
|
||||||
|
(not (directory-empty-p stream-dir))
|
||||||
|
(not (directory-empty-p playlist-dir)))))
|
||||||
|
|
||||||
|
(defun creature/is-iso-file (filename)
|
||||||
|
(and (string-equal (downcase (or (file-name-extension filename) "")) "iso")
|
||||||
|
(file-exists-p filename)))
|
||||||
|
|
||||||
|
(defun creature/open-by-mpv (filename)
|
||||||
|
(cond
|
||||||
|
((creature/is-bd-dir filename)
|
||||||
|
(call-process "mpv" nil 0 nil filename))
|
||||||
|
((creature/is-iso-file filename)
|
||||||
|
(call-process "mpv" nil 0 nil
|
||||||
|
"bd://"
|
||||||
|
(concat "--bluray-device=" filename)))
|
||||||
|
(t
|
||||||
|
(call-process "mpv" nil 0 nil filename))))
|
||||||
|
|
||||||
|
(defun creature/mpv ()
|
||||||
|
(interactive)
|
||||||
|
(let ((filename (if (derived-mode-p 'dired-mode)
|
||||||
|
(dired-get-file-for-visit)
|
||||||
|
(buffer-file-name))))
|
||||||
|
(when filename (creature/open-by-mpv filename))))
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; indentation ;;
|
;; indentation ;;
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|||||||
@@ -81,6 +81,7 @@
|
|||||||
("be" . eval-buffer)
|
("be" . eval-buffer)
|
||||||
|
|
||||||
("fi" . creature/open-init-file)
|
("fi" . creature/open-init-file)
|
||||||
|
("fm" . creature/mpv)
|
||||||
("fo" . creature/open-file-or-directory-in-external-app)
|
("fo" . creature/open-file-or-directory-in-external-app)
|
||||||
("fj" . dired-jump)
|
("fj" . dired-jump)
|
||||||
("ff" . find-file)
|
("ff" . find-file)
|
||||||
|
|||||||
Reference in new issue
Block a user