add to the queue pause continue mode bury the buffer kill it"))
(defun media/move-forward () (interactive) (media/api/jump-at-time 'relative 3))
(defun media/move-backward () (interactive) (media/api/jump-at-time 'relative -3))
(defun media/volume-reset () (interactive) (media/api/set-volume 'absolute 50))
(defun media/volume-increase () (interactive) (media/api/set-volume 'relative 1))
(defun media/volume-decrease () (interactive) (media/api/set-volume 'relative -1))
(defun media/mode () (interactive)
(if media/buffer (error "We already have a media buffer"))
(kill-all-local-variables)
(unless (boundp 'media/mode-map)
(setq media/mode-map (make-sparse-keymap))
(suppress-keymap media/mode-map)
(mapc (lambda (x) (define-key media/mode-map (car x) (cdr x)))
`(("p" . media/pause)
("\C-m" . media/play-or-active-at-point)
("\t" . media/goto-next-playlist-or-dir)
([(shift iso-lefttab)] . media/goto-previous-playlist-or-dir)
(" " . media/goto-current)
("a" . media/add-song-at-point-to-active-playlist)
("A" . media/add-current-song-to-active-playlist)
("n" . media/queue-song-at-point)
("f" . media/show-id3-at-point)
("r" . media/rename-point)
("R" . media/rename-point-according-to-id3)
("K" . media/move-point-to-tmp)
("N" . media/play-next)
("P" . media/play-prev)
("q" . bury-buffer)
("k" . media/save-and-kill-buffer)
("s" . media/stop)
("m" . media/switch-continue-mode)
;; ("t" . media/switch-timing)
("g" . media/refresh-list)
("h" . media/quick-help)
("?" . media/quick-help)
("l" . media/select-active-playlist)
;; ("L" . media/create-playlist)
("i" . media/show-current-information)
;; ("I" . media/edit-id3-at-point)
("j" . media/jump-at-percent)
(">" . media/move-forward)
("<" . media/move-backward)
([(control >)] . (lambda () (interactive) (media/api/jump-at-time 'relative 30)))
([(control <)] . (lambda () (interactive) (media/api/jump-at-time 'relative -30)))
([(control x) (control s)] . media/save-playlists)
("=" . media/volume-reset)
("+" . media/volume-increase)
("-" . media/volume-decrease)
)))
(setq major-mode 'media
mode-name "Media"
;; buffer-read-only t
truncate-lines t
media/buffer (current-buffer)
media/current-overlay (make-overlay 0 0)
media/instant-highlight-overlay (make-overlay 0 0)
media/song-current-time nil
media/song-duration nil
global-mode-string (append global-mode-string '((:eval (media/mode-string))))
)
(overlay-put media/current-overlay 'face 'media/current-tune-face)
(overlay-put media/instant-highlight-overlay 'face 'media/instant-highlight-face)
(use-local-map media/mode-map)
(add-hook 'kill-emacs-hook 'media/die-decently)
(add-hook 'kill-buffer-hook 'media/kill-buffer-cleanup nil t)
(add-hook 'write-contents-hooks 'media/save-buffer nil t)
)
(defun media/die-decently ()
(when media/add-current-song-to-interrupted-when-killing
(condition-case nil
(progn
(setq media/active-playlist "Interrupted")
(media/add-current-song-to-active-playlist t)
(media/save-playlists))
(error nil))
)
)
(defun media/kill-buffer-cleanup () (interactive)
(media/api/cleanup)
(setq media/buffer nil
global-mode-string (remove '(:eval (media/mode-string)) global-mode-string))
)
(defun media/full-refresh ()
(undo-boundary)
(erase-buffer)
(media/import media/url-list)
(media/goto-top)
(media/load-playlists)
(unless media/expert
(insert (propertize "
media.el
Written and (C) Francois Fleuret
Send comments and bug reports to francois@fleuret.org
Return play or active the playlist for insertion
Space goto song playing
p pause
g refresh list
a insert song at point to the active playlist
A insert current song to the active playlist
universal argument store the time too
l select active playlist
C-x C-s save playlists
n queue song for playing
f show ID3 of song
r rename song
R rename song according to ID3
K move song to /tmp
N play next
P play previous
q hide buffer
k stop song and kill buffer
s stop song
m switch the continuous mode
i show current song information
j jump at position
> fast forward
< fast backward
Ctrl-> fast forward x10
Ctrl-< fast backward x10
= reset volume
+ increase volume
- decrease volume
" 'prologue t)))
(set-buffer-modified-p nil)
(undo-boundary)
)
(defun media/switch-to-buffer-or-window (buffer)
(let ((w (get-buffer-window buffer)))
(if w (select-window w)
(switch-to-buffer buffer))))
(defun media ()
"If a `media/buffer' exists, and we are not in it, switch to it, if
we are already in it, bury it. If none exists, creates one and switch
to it."
(interactive)
(if media/buffer
(if (eq (window-buffer (selected-window)) media/buffer)
(bury-buffer)
(media/switch-to-buffer-or-window media/buffer))
(switch-to-buffer (get-buffer-create "*media*"))
(buffer-disable-undo)
(media/mode)
(media/full-refresh)
(buffer-enable-undo)
(run-hooks 'media/starting-hook)
)
)
(load media/player-api)
(media/api/init)