aboutsummaryrefslogtreecommitdiffhomepage
path: root/player
diff options
context:
space:
mode:
authorGravatar wm4 <wm4@nowhere>2015-06-11 21:20:39 +0200
committerGravatar wm4 <wm4@nowhere>2015-06-11 21:42:09 +0200
commitce513dedd8b61509d58aa3d76551e1aad36573f2 (patch)
treeda0c281ed44930a8b95189bfea72ed525f9aeefa /player
parent478ea1d0f3a4c220f9b07f24412be7f5867e7719 (diff)
lua: export end-file event fields
Diffstat (limited to 'player')
-rw-r--r--player/lua.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/player/lua.c b/player/lua.c
index 2e00f79dda..7f4e2405de 100644
--- a/player/lua.c
+++ b/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);