branch: externals/emms
commit 0ea4a3d3be11a64e9fbb313f6405ed72ab68a3bf
Author: Morgan Smith <morgan.j.sm...@outlook.com>
Commit: Morgan Smith <morgan.j.sm...@outlook.com>

    * emms-player-mpd.el: Only play using MPD if the file is in the right 
directory
    
    Check to see if the file is in `emms-player-mpd-music-directory'.
---
 emms-player-mpd.el | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/emms-player-mpd.el b/emms-player-mpd.el
index 3b4587d9bb..01d8e7555f 100644
--- a/emms-player-mpd.el
+++ b/emms-player-mpd.el
@@ -896,11 +896,19 @@ Execute CALLBACK with CLOSURE as its first argument when 
done."
   "Return non-nil when we can play this track."
   (and (memq (emms-track-type track) '(file url playlist streamlist))
        (string-match (emms-player-get emms-player-mpd 'regex)
-                    (emms-track-name track))
-       (condition-case nil
-          (progn (emms-player-mpd-ensure-process)
-                 t)
-        (error nil))))
+                     (emms-track-name track))
+       ;; Detect if file is in the MPD directory.  We could use the "listall"
+       ;; command and ask MPD directly but this is easier, quicker, and likely
+       ;; good enough
+       (if (and emms-player-mpd-music-directory
+                (eq (emms-track-type track) 'file)
+                (file-accessible-directory-p emms-player-mpd-music-directory))
+           (file-in-directory-p (emms-track-get track 'name)
+                                emms-player-mpd-music-directory)
+         t)
+       (ignore-errors
+         (emms-player-mpd-ensure-process)
+         t)))
 
 (defun emms-player-mpd-play (&optional id)
   "Play whatever is in the current MusicPD playlist.

Reply via email to