diff options
author | Ricardo Constantino <wiiaboo@gmail.com> | 2018-01-02 14:20:53 +0000 |
---|---|---|
committer | Ricardo Constantino <wiiaboo@gmail.com> | 2018-01-02 16:01:22 +0000 |
commit | 89f81da481c81cda1abd7c971b36f00ea80d80fe (patch) | |
tree | 612e6d89e775e41c3e5270b59c92c6c13b6c8b73 /player | |
parent | 97816bbef0f97cfda7abdbe560707481d5f68ccd (diff) | |
download | mpv-89f81da481c81cda1abd7c971b36f00ea80d80fe.tar.bz2 mpv-89f81da481c81cda1abd7c971b36f00ea80d80fe.tar.xz |
player: add on_load_fail hook
Diffstat (limited to 'player')
-rw-r--r-- | player/loadfile.c | 15 | ||||
-rw-r--r-- | player/lua/ytdl_hook.lua | 2 |
2 files changed, 12 insertions, 5 deletions
diff --git a/player/loadfile.c b/player/loadfile.c index ca782f88d8..c54204db0b 100644 --- a/player/loadfile.c +++ b/player/loadfile.c @@ -734,12 +734,12 @@ static void transfer_playlist(struct MPContext *mpctx, struct playlist *pl) } } -static int process_open_hooks(struct MPContext *mpctx) +static int process_open_hooks(struct MPContext *mpctx, char *name) { - mp_hook_run(mpctx, NULL, "on_load"); + mp_hook_run(mpctx, NULL, name); - while (!mp_hook_test_completion(mpctx, "on_load")) { + while (!mp_hook_test_completion(mpctx, name)) { mp_idle(mpctx); if (mpctx->stop_play) { // Can't exit immediately, the script would interfere with the @@ -1214,7 +1214,7 @@ reopen_file: assert(mpctx->demuxer == NULL); - if (process_open_hooks(mpctx) < 0) + if (process_open_hooks(mpctx, "on_load") < 0) goto terminate_playback; if (opts->stream_dump && opts->stream_dump[0]) { @@ -1224,6 +1224,13 @@ reopen_file: } open_demux_reentrant(mpctx); + if (!mpctx->stop_play && !mpctx->demuxer && + process_open_hooks(mpctx, "on_load_fail") >= 0 && + strcmp(mpctx->stream_open_filename, mpctx->filename) != 0) + { + mpctx->error_playing = MPV_ERROR_LOADING_FAILED; + open_demux_reentrant(mpctx); + } if (!mpctx->demuxer || mpctx->stop_play) goto terminate_playback; diff --git a/player/lua/ytdl_hook.lua b/player/lua/ytdl_hook.lua index f20eed70d1..8a75fa7e3d 100644 --- a/player/lua/ytdl_hook.lua +++ b/player/lua/ytdl_hook.lua @@ -301,7 +301,7 @@ local function add_single_video(json) end end -mp.add_hook("on_load", 10, function () +mp.add_hook("on_load_fail", 10, function () local url = mp.get_property("stream-open-filename") local start_time = os.clock() if (url:find("ytdl://") == 1) or |