mmedia.el 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. ;;; mmedia.el --- Using multimedia stuff inside Emacs
  2. ;; Copyright © 2014–2018 Alex Kost
  3. ;; This program is free software; you can redistribute it and/or modify
  4. ;; it under the terms of the GNU General Public License as published by
  5. ;; the Free Software Foundation, either version 3 of the License, or
  6. ;; (at your option) any later version.
  7. ;;
  8. ;; This program is distributed in the hope that it will be useful,
  9. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. ;; GNU General Public License for more details.
  12. ;;
  13. ;; You should have received a copy of the GNU General Public License
  14. ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. (require 'al-key)
  16. ;;; EMMS
  17. (setq
  18. emms-directory (al/emacs-data-dir-file "emms")
  19. emms-playlist-sort-prefix "s")
  20. (al/bind-keys
  21. :prefix-map al/emms-map
  22. :prefix-docstring "Map for EMMS."
  23. :prefix [ctrl-m]
  24. ("SPC" . emms-pause)
  25. ("M-SPC" . emms-stop)
  26. ("s" . al/emms-show)
  27. ("m" . emms-state-toggle-mode-line)
  28. ("n" . al/emms-notification-mode)
  29. ("b" . emms-browser)
  30. ("l" . emms)
  31. ("r" . emms-streams)
  32. ("g" . al/emms-seek-to)
  33. ("y" . al/emms-mpv-sync-playing-time)
  34. ("S" . emms-cache-save)
  35. ("u" (emms-playlist-simple-uniq)))
  36. (al/bind-keys
  37. :map al/emms-map
  38. :prefix-map al/emms-play-map
  39. :prefix-docstring "Map for playing EMMS entries."
  40. :prefix "p"
  41. ("t" . emms-play-directory-tree)
  42. ("d" . emms-play-directory)
  43. ("f" . emms-play-file)
  44. ("l" . emms-play-playlist)
  45. ("u" . emms-play-url)
  46. ("e" (emms-play-file
  47. (read-file-name "Play file: " al/echo-download-dir))))
  48. (al/bind-keys
  49. :map al/emms-map
  50. :prefix-map al/emms-add-map
  51. :prefix-docstring "Map for adding EMMS entries."
  52. :prefix "a"
  53. ("t" . emms-add-directory-tree)
  54. ("d" . emms-add-directory)
  55. ("f" . emms-add-file)
  56. ("l" . emms-add-playlist)
  57. ("u" . emms-add-url)
  58. ("e" (emms-add-file
  59. (read-file-name "Add file: " al/echo-download-dir))))
  60. (with-eval-after-load 'emms
  61. (require 'emms-source-file)
  62. (require 'emms-source-playlist)
  63. (require 'emms-player-mplayer)
  64. (require 'emms-info)
  65. (require 'emms-playlist-mode)
  66. (require 'emms-mark)
  67. (require 'emms-streams)
  68. (require 'emms-playlist-sort)
  69. (require 'emms-browser)
  70. (require 'emms-bookmarks)
  71. (require 'emms-last-played)
  72. (require 'emms-metaplaylist-mode)
  73. (require 'emms-history)
  74. (require 'emms-i18n)
  75. (require 'emms-cache)
  76. (setq
  77. emms-playlist-buffer-name "*EMMS Playlist*"
  78. emms-mode-line-format " %s"
  79. emms-playing-time-display-format " %s"
  80. emms-playlist-default-major-mode 'emms-playlist-mode
  81. emms-info-functions '(emms-info-libtag emms-info-cueinfo)
  82. emms-show-format "%s"
  83. emms-source-file-default-directory al/music-dir)
  84. (setq emms-player-list '(emms-player-mplayer))
  85. (when (and (executable-find "mpv")
  86. (require 'al-emms-mpv nil t))
  87. (push 'emms-player-mpv emms-player-list))
  88. ;; Do not add `emms-cache-save' to `kill-emacs-hook'.
  89. (let ((noninteractive t)) (emms-cache 1))
  90. (push 'emms-info-initialize-track emms-track-initialize-functions)
  91. (al/add-hook-maybe 'emms-player-started-hook
  92. 'emms-last-played-update-current)
  93. (when (require 'emms-state nil t)
  94. (emms-state-mode))
  95. (when (require 'al-emms nil t)
  96. (setq
  97. emms-mode-line-mode-line-function 'al/emms-mode-line-song-string
  98. emms-track-description-function 'al/emms-full-track-description)
  99. (advice-add 'emms-source-play
  100. :override 'al/emms-source-add-and-play)))
  101. (with-eval-after-load 'emms-playlist-mode
  102. (defconst al/emms-playlist-keys
  103. '(("SPC" . emms-pause)
  104. ("S" . emms-stop)
  105. ("u" . emms-playlist-mode-play-smart)
  106. ("j" . emms-playlist-mode-goto-dired-at-point)
  107. ("w" . al/emms-playlist-wget)
  108. ("C-j" . emms-playlist-mode-insert-newline)
  109. ("C-k" (beginning-of-line) (emms-playlist-mode-kill-entire-track))
  110. ("C-t" . emms-playlist-mode-kill)
  111. ("H-u" . emms-playlist-mode-undo)
  112. ("[" . al/emms-mpv-speed-down)
  113. ("]" . al/emms-mpv-speed-up)
  114. ("DEL" . al/emms-mpv-speed-normal)
  115. ("o" . al/emms-mpv-show-progress)
  116. ("z" . al/emms-mpv-switch-volume)
  117. ("<left>" (al/emms-seek-backward 10))
  118. ("<right>" (al/emms-seek-forward 10))
  119. ("<C-left>" (al/emms-seek-backward 3))
  120. ("<C-right>" (al/emms-seek-forward 3))
  121. ("<M-left>" (al/emms-seek-backward 60))
  122. ("<M-right>" (al/emms-seek-forward 60))
  123. ("<S-left>" (al/emms-seek-backward 600))
  124. ("<S-right>" (al/emms-seek-forward 600))
  125. ("<up>" (al/set-sound "3%+"))
  126. ("<down>" (al/set-sound "3%-"))
  127. ("<C-up>" (al/set-sound "1%+"))
  128. ("<C-down>" (al/set-sound "1%-"))
  129. ("<M-up>" (al/set-sound "10%+"))
  130. ("<M-down>" (al/set-sound "10%-")))
  131. "Alist of auxiliary keys for `emms-playlist-mode-map'.")
  132. (al/bind-keys-from-vars 'emms-playlist-mode-map
  133. '(al/free-misc-keys al/lazy-moving-keys al/emms-playlist-keys)
  134. t)
  135. (suppress-keymap emms-playlist-mode-map)
  136. (al/add-hook-maybe 'emms-playlist-mode-hook
  137. '(al/mode-name hl-line-mode)))
  138. (with-eval-after-load 'emms-streams
  139. (defconst al/emms-stream-keys
  140. '(("." . emms-stream-previous-line)
  141. ("e" . emms-stream-next-line)
  142. ("u" . emms-stream-play))
  143. "Alist of auxiliary keys for `emms-stream-mode-map'.")
  144. (al/bind-keys-from-vars 'emms-stream-mode-map 'al/emms-stream-keys)
  145. (al/add-hook-maybe 'emms-stream-hook
  146. '(al/mode-name hl-line-mode)))
  147. (with-eval-after-load 'later-do
  148. (setq later-do-interval 0.1))
  149. (al/autoload "emms-cue" emms-info-cueinfo)
  150. (al/autoload "emms-info-libtag" emms-info-libtag)
  151. (with-eval-after-load 'al-emms-notification
  152. (setq
  153. al/emms-notification-artist-format "<big>%s</big>"
  154. al/emms-notification-title-format "<span foreground=\"yellow\">%s</span>"
  155. al/emms-notification-year-format "<span foreground=\"#84ebeb\">%s</span>"))
  156. ;;; mmedia.el ends here