summary refs log tree commit diff stats
path: root/lisp/+emms.el
blob: a43daeac89cbc51efad51927795a1e1f154c7ffa (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
;;; +emms.el  -*- lexical-binding: t; -*-

(defun +emms-streams (&optional file)
  "Better interface for `emms-streams'.
If FILE is non-nil, use it.  Otherwise use `emms-streams-file'.
If `emms-streams-file' is nil or this function is called with
\\[universal-argument], prompt the user."
  (interactive
   (list (cond
          ((or emms-streams-file
               (not current-prefix-arg))
           emms-streams-file)
          (:else (read-file-name "Stream file: "
                                 emms-source-file-default-directory)))))
  (when (and (not (file-exists-p emms-streams-file))
             (y-or-n-p "Emms' bulit-in streams file hasn't been installed yet. Install it now?"))
    (emms-streams-install))
  (let ((buf (get-buffer emms-streams-buffer-name)))
    (when (not buf)
      (with-current-buffer (get-buffer-create emms-streams-buffer-name)
        (setq buf (current-buffer))
        (emms-playlist-mode)
        (setq emms-playlist-buffer-p t)
        (emms-playlist-set-playlist-buffer (current-buffer))
        (with-current-buffer (find-file-noselect emms-streams-file)
          (cond
           ((emms-source-playlist-native-p)
            (emms-add-native-playlist emms-streams-file))
           ((emms-source-playlist-m3u-p)
            (emms-add-m3u-playlist emms-streams-file))
           ((emms-source-playlist-pls-p)
            (emms-add-pls-playlist emms-streams-file))
           (:else (error "Streams file `%s' isn't in a known format."
                         emms-streams-file))))))
    (switch-to-buffer buf)))

(provide '+emms)
;;; +emms.el ends here