Skip to content

Commit 502c2af

Browse files
committed
client: add MPV_EVENT_INITIALIZED
This may be useful for waiting until all scripts have finished loading. Use with caution, as scripts shouldn't perform too many tasks during initialization or afterward. Instead, they should wait to be triggered by property or event changes.
1 parent 228f386 commit 502c2af

File tree

5 files changed

+13
-0
lines changed

5 files changed

+13
-0
lines changed

DOCS/client-api-changes.rst

+2
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ API changes
3232

3333
::
3434

35+
--- mpv 0.40.0 ---
36+
2.5 - add MPV_EVENT_INITIALIZED event
3537
--- mpv 0.39.0 ---
3638
2.4 - mpv_render_param with the MPV_RENDER_PARAM_ICC_PROFILE argument no
3739
longer has incorrect assumptions about memory allocation and can be

DOCS/man/input.rst

+4
Original file line numberDiff line numberDiff line change
@@ -1722,6 +1722,10 @@ This list uses the event name field value, and the C API symbol in brackets:
17221722
``data``
17231723
The new value of the property.
17241724

1725+
``initialized`` (``MPV_EVENT_INITIALIZED``)
1726+
Triggered after initialization is complete, including all scripts.
1727+
mpv is proceeding to to play the file.
1728+
17251729
The following events also happen, but are deprecated: ``idle``, ``tick``
17261730
Use ``mpv_observe_property()`` (Lua: ``mp.observe_property()``) instead.
17271731

libmpv/client.h

+5
Original file line numberDiff line numberDiff line change
@@ -1368,6 +1368,11 @@ typedef enum mpv_event_id {
13681368
* See also mpv_event and mpv_event_hook.
13691369
*/
13701370
MPV_EVENT_HOOK = 25,
1371+
/**
1372+
* Triggered after initialization is complete, including all scripts.
1373+
* mpv is proceeding to to play the file.
1374+
*/
1375+
MPV_EVENT_INITIALIZED = 26,
13711376
// Internal note: adjust INTERNAL_EVENT_BASE when adding new events.
13721377
} mpv_event_id;
13731378

player/client.c

+1
Original file line numberDiff line numberDiff line change
@@ -2114,6 +2114,7 @@ static const char *const event_table[] = {
21142114
[MPV_EVENT_PROPERTY_CHANGE] = "property-change",
21152115
[MPV_EVENT_QUEUE_OVERFLOW] = "event-queue-overflow",
21162116
[MPV_EVENT_HOOK] = "hook",
2117+
[MPV_EVENT_INITIALIZED] = "initialized",
21172118
};
21182119

21192120
const char *mpv_event_name(mpv_event_id event)

player/loadfile.c

+1
Original file line numberDiff line numberDiff line change
@@ -2015,6 +2015,7 @@ void mp_play_files(struct MPContext *mpctx)
20152015
}
20162016
// After above is finished; but even if it's skipped.
20172017
mp_msg_set_early_logging(mpctx->global, false);
2018+
mp_notify(mpctx, MPV_EVENT_INITIALIZED, NULL);
20182019

20192020
prepare_playlist(mpctx, mpctx->playlist);
20202021

0 commit comments

Comments
 (0)