mirror of https://github.com/mpv-player/mpv
lua: export end-file event fields
This commit is contained in:
parent
478ea1d0f3
commit
ce513dedd8
|
@ -690,6 +690,23 @@ List of events
|
|||
Happens after a file was unloaded. Typically, the player will load the
|
||||
next file right away, or quit if this was the last file.
|
||||
|
||||
The event has the ``reason`` field, which takes one of these values:
|
||||
|
||||
``eof``
|
||||
The file has ended. This can (but doesn't have to) include
|
||||
incomplete files or broken network connections under
|
||||
circumstances.
|
||||
|
||||
``stop``
|
||||
Playback was ended by a command.
|
||||
|
||||
``quit``
|
||||
Playback was ended by sending the quit command.
|
||||
|
||||
``error``
|
||||
An error happened. In this case, an ``error`` field is present with
|
||||
the error string.
|
||||
|
||||
``file-loaded``
|
||||
Happens after a file was loaded and begins playback.
|
||||
|
||||
|
|
20
player/lua.c
20
player/lua.c
|
@ -512,6 +512,26 @@ static int script_wait_event(lua_State *L)
|
|||
lua_setfield(L, -2, "args"); // event
|
||||
break;
|
||||
}
|
||||
case MPV_EVENT_END_FILE: {
|
||||
mpv_event_end_file *eef = event->data;
|
||||
const char *reason;
|
||||
switch (eef->reason) {
|
||||
case MPV_END_FILE_REASON_EOF: reason = "eof"; break;
|
||||
case MPV_END_FILE_REASON_STOP: reason = "stop"; break;
|
||||
case MPV_END_FILE_REASON_QUIT: reason = "quit"; break;
|
||||
case MPV_END_FILE_REASON_ERROR: reason = "error"; break;
|
||||
default:
|
||||
reason = "unknown";
|
||||
}
|
||||
lua_pushstring(L, reason); // event reason
|
||||
lua_setfield(L, -2, "reason"); // event
|
||||
|
||||
if (eef->reason == MPV_END_FILE_REASON_ERROR) {
|
||||
lua_pushstring(L, mpv_error_string(eef->error)); // event error
|
||||
lua_setfield(L, -2, "error"); // event
|
||||
}
|
||||
break;
|
||||
}
|
||||
case MPV_EVENT_PROPERTY_CHANGE: {
|
||||
mpv_event_property *prop = event->data;
|
||||
lua_pushstring(L, prop->name);
|
||||
|
|
Loading…
Reference in New Issue