(interactive)
(emus-volume-increase-by -10))
-(defun emus-play-nearby (offset)
- (let ((idx (seq-position emus-records emus-current-record)))
- (if idx
- (let ((next-record (elt emus-records (+ idx offset))))
- (if next-record
- (if (eq emus-state 'playing)
- (emus-play-record next-record)
- (emus-select-record next-record))
- (error "Track does not exist")))
- (error "No track is currently selected"))))
+(defun emus--play-adjacent-track (&optional prev)
+ (emus--with-library
+ (let ((idx (seq-position emus-records emus-current-record))
+ (offset (if prev -1 +1)))
+ (if idx
+ (let ((next-record (elt emus-records (+ idx offset))))
+ (if next-record
+ (if (eq emus-state 'playing)
+ (emus-play-record next-record)
+ (emus-select-record next-record))
+ (error "Track does not exist")))
+ (error "No track selected")))))
+
+(defun emus--play-adjacent-album (&optional prev)
+ (emus--with-library
+ (let ((idx (seq-position emus-records emus-current-record)))
+ (if idx
+ (let* ((search-list (if prev
+ (reverse (seq-subseq emus-records 0 idx))
+ (seq-subseq emus-records (+ idx 1))))
+ (current-album (emus-record-album emus-current-record))
+ (next-record (seq-some (lambda (r)
+ (if (string= (emus-record-album r)
+ current-album)
+ nil
+ r))
+ search-list)))
+ (if next-record
+ (if (eq emus-state 'playing)
+ (emus-play-record next-record)
+ (emus-select-record next-record))
+ (error "Track does not exist")))
+ (error "No track selected")))))
(defun emus-play-next ()
(interactive)
- (emus-play-nearby 1))
+ (emus--play-adjacent-track))
(defun emus-play-prev ()
(interactive)
- (emus-play-nearby -1))
+ (emus--play-adjacent-track t))
+
+(defun emus-play-next-album ()
+ (interactive)
+ (emus--play-adjacent-album))
+
+(defun emus-play-prev-album ()
+ (interactive)
+ (emus--play-adjacent-album t))
(defun emus-display-status ()
(interactive)
(defun emus-refresh-status () (interactive) (emus-refresh) (emus-display-status))
(defun emus-play-next-status () (interactive) (emus-play-next) (emus-display-status))
(defun emus-play-prev-status () (interactive) (emus-play-prev) (emus-display-status))
+(defun emus-play-next-album-status () (interactive) (emus-play-next-album) (emus-display-status))
+(defun emus-play-prev-album-status () (interactive) (emus-play-prev-album) (emus-display-status))
(defun emus-centre-current-status () (interactive) (emus-centre-current) (emus-display-status))
(defvar emus-browser-mode-map
(define-key map (kbd "R") 'emus-refresh-status)
(define-key map (kbd "n") 'emus-play-next-status)
(define-key map (kbd "p") 'emus-play-prev-status)
+ (define-key map (kbd "N") 'emus-play-next-album-status)
+ (define-key map (kbd "P") 'emus-play-prev-album-status)
(define-key map (kbd "c") 'emus-centre-current-status)
(when (fboundp 'evil-define-key*)
(evil-define-key* 'motion map
(kbd "R") 'emus-refresh-status
(kbd "n") 'emus-play-next-status
(kbd "p") 'emus-play-prev-status
+ (kbd "N") 'emus-play-next-album-status
+ (kbd "P") 'emus-play-prev-album-status
(kbd "c") 'emus-centre-current-status))
map)
"Keymap for emus.")