"eof-reached" inconsistent behavior
I noticed some inconsistent behavior in how the eof-reached property is set.
- Normal playback to the end would set this property while seeking past the end would not.
- Seeking from the end would not clear the property. It would only be cleared after a pause/unpause.
- Depending on the moment the
pauseproperty is set in Lua theeof-reachedproperty might not change. See the short examples below.
-- Does not change the "eof-reached" property
function eofHandler(name, val)
if val then
mp.set_property_number('percent-pos', 50)
mp.set_property_bool('pause', false)
end
end
mp.observe_property('eof-reached', 'bool', eofHandler)
-- Changes the "eof-reached" property
local unpause = false
function eofHandler(name, val)
if val then
mp.set_property_number('percent-pos', 50)
unpause = true
end
end
mp.observe_property('eof-reached', 'bool', eofHandler)
function seekUnpause()
if unpause then
unpause = false
mp.set_property_bool('pause', false)
end
end
mp.register_event('seek', seekUnpause)
I'm having trouble following this description. Is this with --keep-open or so?
Yes this is with keep-open.
One problem with your expectations is that --keep-open seeks to the last video frame when seeking past it, but at this point the file didn't necessarily end - there could still be audio left.
One problem with your expectations is that --keep-open seeks to the last video frame when seeking past it, but at this point the file didn't necessarily end - there could still be audio left.
Ok just tested without audio and you are right. This addressed my 1st point.
My 2nd point: It turns out that the property is being set correctly all along. Its just Lua that fails to observe the change of the property.
Try setting --osd-msg1="eof-reached: ${eof-reached}" and the Lua script
function eofHandler(name, val)
mp.msg.info('eof-reached: ' .. tostring(val))
end
mp.observe_property('eof-reached', 'bool', eofHandler)
When eof is reached it would be shown on the OSD and in the console. Next try seeking to the middle. Seeking to the middle of the file will only result in the OSD message being updated. Lua seems to fail to observe the change in the property until the video is unpaused.
My 3rd point: Why does the 2 Lua scripts in my first post results in completely different behavior? The first one will play the file to the end, seek to the middle, play to the end and pause. The second one will play to the end and continuously loop from the middle to the end.
Ok just tested without audio and you are right. This addressed my 1st point.
Still not entirely what one would expect. Maybe it could just seek to the end of anything, and keep the last video frame. But it's messy.
Lua seems to fail to observe the change in the property until the video is unpaused.
Fixed this one, hopefully.
The first one will play the file to the end, seek to the middle, play to the end and pause.
Can't reproduce anymore after the change, but I didn't try too hard.