Mpv: Question: Is it possible to prevent automatically skipping unplayable items in the playlist?

Created on 3 Feb 2019  ·  5Comments  ·  Source: mpv-player/mpv

Sometimes when playing a playlist, e.g. with youtube URLs, youtube-dl fails to find a JS function and the video is silently skipped without me knowing. If I could just become aware of the problem I can easily update youtube-dl, which always solves it.

Is there a way to make mpv not continue to the next item in the playlist if it fails to play the current item? Is this configurable at all? I'm using mpv through IINA but was assured that this behavior is actually inherited by mpv, so I wanted to investigate what's currently possible. I couldn't find any mention of this behavior on the mpv manual page, nor in a previous issue.

question

Most helpful comment

You can copy the ytdl_hook.lua, edit it and add it to your scripts.

Change the following:

    if (es < 0) or (json == nil) or (json == "") then
        local err = "youtube-dl failed: "

To this:

    if (es < 0) or (json == nil) or (json == "") then
        local err = "youtube-dl failed: "
        mp.set_property_native("pause", true)
        mp.osd_message("ytdl paused because of playback error", 5000)

I'm not sure if this catches all of the errors but at least it's a start. You can take a look at other msg.error locations if they need the same behavior.

All 5 comments

You can copy the ytdl_hook.lua, edit it and add it to your scripts.

Change the following:

    if (es < 0) or (json == nil) or (json == "") then
        local err = "youtube-dl failed: "

To this:

    if (es < 0) or (json == nil) or (json == "") then
        local err = "youtube-dl failed: "
        mp.set_property_native("pause", true)
        mp.osd_message("ytdl paused because of playback error", 5000)

I'm not sure if this catches all of the errors but at least it's a start. You can take a look at other msg.error locations if they need the same behavior.

@jonniek
I haven't tried it yet but that looks very helpful, thank you! I'll play around and see what comes of it.

If anyone happens to know, I am still interested in if there exist any more general customization points that deal with all kinds of playback error, i.e. that catches non-youtube-dl related errors as well.

end-file event could provide useful for general errors, something like this:

mp.register_event(
  'end-file',
  function(reason, error)
    if reason == 'error' then
      mp.set_property_native('pause', true)
      mp.osd_message("Paused because of a playback error")
      mp.msg.error(error)
    end
  end
)

I can't test it because I'm not sure what kind of file would cause this error. Files that can't be loaded(like a failing youtube url) will at least not trigger this. Maybe there is an easy way to listen to the output and react on any error log but I'm not aware of one. You could do some hacky things with sterr, pipes and ipc-sockets but it seems a bit backwards.

on_load_fail seems relevant.

I ended up finding MPV_EVENT_END_FILE thanks to the second code snippet. It seems to fire when this happens. In the absence of native configuration of this behavior I'm guessing this is the way to go 👍

Was this page helpful?
0 / 5 - 0 ratings

Related issues

422658476 picture 422658476  ·  3Comments

532910 picture 532910  ·  3Comments

laichiaheng picture laichiaheng  ·  3Comments

ww7 picture ww7  ·  3Comments

WoLpH picture WoLpH  ·  3Comments