mirror of https://github.com/mpv-player/mpv
lua: restore recent end-file event, and deprecate it
Lua changed behavior for this specific event. I considered the change minor enough that it would not need to go through deprecation, but someone hit it immediately and ask on the -dev channel. It's probably better to restore the behavior. But mark it as deprecated, since it's problematic (mismatch with the C API). Unfortunately, no automatic warning is possible. (Or maybe it is, by playing sophisticated Lua tricks such as setting a metatable and overriding indexing, but let's not.)
This commit is contained in:
parent
3fedf61532
commit
37f441d61b
|
@ -54,8 +54,10 @@ Interface changes
|
|||
Using the "playlist-play-index" command is recommended instead.
|
||||
- add "playlist-play-index" command
|
||||
- add playlist-current-pos, playlist-playing-pos properties
|
||||
- Lua end-file events do not set the "error" field anymore, use "file_error"
|
||||
instead.
|
||||
- Lua end-file events set the "error" field; this is deprecated; use the
|
||||
"file_error" instead for this specific event. Scripts relying on the
|
||||
"error" field for end-file will silently break at some point in the
|
||||
future.
|
||||
- deprecate encoding mode (lack of maintainer)
|
||||
--- mpv 0.32.0 ---
|
||||
- change behavior when using legacy option syntax with options that start
|
||||
|
|
|
@ -1350,8 +1350,9 @@ This list uses the event name field value, and the C API symbol in brackets:
|
|||
``file_error``
|
||||
Set to mpv error string describing the approximate reason why playback
|
||||
failed. Unset if no error known. (In Lua scripting, this value was set
|
||||
on the ``error`` field directly before mpv 0.33.0. Now the ``error``
|
||||
field always indicates success, i.e. is not set.)
|
||||
on the ``error`` field directly. This is deprecated since mpv 0.33.0.
|
||||
In the future, this ``error`` field will be unset for this specific
|
||||
event.)
|
||||
|
||||
``file-loaded`` (``MPV_EVENT_FILE_LOADED``)
|
||||
Happens after a file was loaded and begins playback.
|
||||
|
|
|
@ -498,7 +498,7 @@ static int script_resume_all(lua_State *L)
|
|||
|
||||
static void pushnode(lua_State *L, mpv_node *node);
|
||||
|
||||
static int script_wait_event(lua_State *L)
|
||||
static int script_raw_wait_event(lua_State *L)
|
||||
{
|
||||
struct script_ctx *ctx = get_ctx(L);
|
||||
|
||||
|
@ -1159,7 +1159,7 @@ static const struct fn_entry main_fns[] = {
|
|||
FN_ENTRY(suspend),
|
||||
FN_ENTRY(resume),
|
||||
FN_ENTRY(resume_all),
|
||||
FN_ENTRY(wait_event),
|
||||
FN_ENTRY(raw_wait_event),
|
||||
FN_ENTRY(request_event),
|
||||
FN_ENTRY(find_config_file),
|
||||
FN_ENTRY(get_script_directory),
|
||||
|
|
|
@ -475,6 +475,15 @@ _G.print = mp.msg.info
|
|||
package.loaded["mp"] = mp
|
||||
package.loaded["mp.msg"] = mp.msg
|
||||
|
||||
function mp.wait_event(t)
|
||||
local r = mp.raw_wait_event(t)
|
||||
if r and r.file_error and not r.error then
|
||||
-- compat; deprecated
|
||||
r.error = r.file_error
|
||||
end
|
||||
return r
|
||||
end
|
||||
|
||||
_G.mp_event_loop = function()
|
||||
mp.dispatch_events(true)
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue