mirror of
https://github.com/mpv-player/mpv
synced 2025-01-13 10:26:09 +00:00
player: add on_preloaded hook
(Limited usefulness.)
This commit is contained in:
parent
b7034db4af
commit
39ab426f05
@ -765,6 +765,17 @@ The following hooks are currently defined:
|
||||
``file-local-options/<option name>``. The player will wait until all
|
||||
hooks are run.
|
||||
|
||||
``on_preloaded``
|
||||
Called after a file has been opened, and before tracks are selected and
|
||||
decoders are created. This has some usefulness if an API users wants
|
||||
to select tracks manually, based on the set of available tracks. It's
|
||||
also useful to initialize ``--lavfi-complex`` in a specific way by API,
|
||||
without having to "probe" the available streams at first.
|
||||
|
||||
Note that this does not yet apply default track selection. Which operations
|
||||
exactly can be done and not be done, and what information is available and
|
||||
what is not yet available yet, is all subject to change.
|
||||
|
||||
``on_unload``
|
||||
Run before closing a file, and before actually uninitializing
|
||||
everything. It's not possible to resume playback in this state.
|
||||
|
@ -871,6 +871,19 @@ static int process_open_hooks(struct MPContext *mpctx)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int process_preloaded_hooks(struct MPContext *mpctx)
|
||||
{
|
||||
mp_hook_run(mpctx, NULL, "on_preloaded");
|
||||
|
||||
while (!mp_hook_test_completion(mpctx, "on_preloaded")) {
|
||||
mp_idle(mpctx);
|
||||
if (mpctx->stop_play)
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void process_unload_hooks(struct MPContext *mpctx)
|
||||
{
|
||||
mp_hook_run(mpctx, NULL, "on_unload");
|
||||
@ -1256,6 +1269,9 @@ reopen_file:
|
||||
|
||||
check_previous_track_selection(mpctx);
|
||||
|
||||
if (process_preloaded_hooks(mpctx))
|
||||
goto terminate_playback;
|
||||
|
||||
if (!init_complex_filters(mpctx))
|
||||
goto terminate_playback;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user