Download
(emms-standard)
(emms-default-players)
(defcustom emms-player-mplayer-subtitle-check-in-streaming
nil
"Enable subtitle check in streaming."
:type 'symbol
:group 'emms)
(defun emms-url-p (name)
(string-match-p
(concat "^" (regexp-opt '("http://" "https://"))) name))
(defun emms-url-or-file-exists-p (name)
(if (emms-url-p name)
(if emms-player-mplayer-subtitle-check-in-streaming
(cond ((string-match-p "^http://" name) (url-http-file-exists-p name))
(t (url-https-file-exists-p name))))
(file-exists-p name)))
(defun emms-player-mplayer-subtitle-checker ()
(let* ((track (emms-playlist-current-selected-track))
(name (emms-track-name track))
(ext (file-name-extension name))
(choices
(emms-remove-if-not 'emms-url-or-file-exists-p
(mapcar (lambda (el)
(emms-replace-regexp-in-string
(concat ext "$") el name))
emms-player-mplayer-subtitle-extensions)))
(subtitle (mapconcat (lambda (el) el) choices ",")))
(unless (string= subtitle "")
(setq emms-player-mplayer-parameters
(append emms-player-mplayer-parameters
(list "-sub" subtitle))))))
(defun emms-track-simple-description (track)
"Simple function to give a user-readable description of a track.
If it's a file track, just return the file name.
Otherwise, return the type and the name with a colon in between."
(if (eq 'file (emms-track-type track))
(emms-track-name track)
(format "%s [%s]"
(let ((name (emms-track-name track)))
(if (emms-url-p name)
(progn
(setq name (w3m-url-decode-string name))
(subst-char-in-string
?/ ?>
(substring
name (+ (posix-string-match "/" name 7) 1)) t))
name))
(symbol-name (emms-track-type track)))))
(provide 'emms-player-streaming-fix)