For some time I've been using a custom-made function for emms-track-description-function with the vlc player. Recently I started using the mpv player with EMMS and with that my custom function causes an error every time a track is read, exemplified by the following backtrace:
Debugger entered--Lisp error: (json-readtable-error 61) json-read() json-read-from-string("=====================================================================================") emms-player-mpv-ipc-recv("=====================================================================================") emms-player-mpv-ipc-filter(#<process emms-player-mpv-ipc> "{\"event\":\"playback-restart\"}\n") My custom function adds lines to the playlist buffer that lack the emms-track property, and apparently the mpv backend does not handle these. I've worked around the error with the following advice: (advice-add #'emms-player-mpv-ipc-recv :before-while (lambda (s) (string-match "^{" s))) I don't know if this error is due to a bug in the mpv backend or if my custom function is unsupported. If the latter, it would be helpful to document the expected format. If this is really a bug in the mpv backend, replacing the above advice with the attached patch prevents the error for me, but I know nothing about the implementation of the mpv JSON IPC interface, so there is probably a better fix. Steve Berman
diff --git a/emms-player-mpv.el b/emms-player-mpv.el index 4b7b908..1683380 100644 --- a/emms-player-mpv.el +++ b/emms-player-mpv.el @@ -651,19 +651,20 @@ errors, if any." Only used with JSON IPC, never called with --input-file as there's no feedback there." (emms-player-mpv-debug-msg "json << %s" json) - (let* - ((json-data (json-read-from-string json)) - (req-id (alist-get 'request_id json-data)) - (ev (alist-get 'event json-data))) - (when req-id - ;; Response to command - (emms-player-mpv-ipc-req-resolve req-id - (alist-get 'data json-data) - (alist-get 'error json-data))) - (when ev - ;; mpv event - (emms-player-mpv-event-handler json-data) - (run-hook-with-args 'emms-player-mpv-event-functions json-data)))) + (when (string-match "^{" json) + (let* + ((json-data (json-read-from-string json)) + (req-id (alist-get 'request_id json-data)) + (ev (alist-get 'event json-data))) + (when req-id + ;; Response to command + (emms-player-mpv-ipc-req-resolve req-id + (alist-get 'data json-data) + (alist-get 'error json-data))) + (when ev + ;; mpv event + (emms-player-mpv-event-handler json-data) + (run-hook-with-args 'emms-player-mpv-event-functions json-data))))) (defun emms-player-mpv-ipc-fifo-cmd (cmd &optional proc) "Send --input-file command string for older mpv versions.