osc.lua: merge the current-tracks/video observer into track-list's#17562
osc.lua: merge the current-tracks/video observer into track-list's#17562guidocella wants to merge 1 commit intompv-player:masterfrom
Conversation
|
|
||
| mp.register_event("file-loaded", function() | ||
| state.file_loaded = true | ||
| state.no_video = mp.get_property_native("current-tracks/video") == nil |
There was a problem hiding this comment.
@na-na-hi was this line needed or is it maybe a leftover from a previous version? It seems to work the same without it.
There was a problem hiding this comment.
If file-loaded event happens before current-tracks/video notification, the icon display will be delayed. Currently it is already delayed because file-loaded arrives later after file is loaded, but deleting this can delay it further.
There was a problem hiding this comment.
Tracks always get deselected before loading a new file though.
There was a problem hiding this comment.
The time sequence currently: end file - logo cleared - load new file - tracks selected - file-loaded arrives - display logo if no video.
The time sequence after change: end file - logo cleared - load new file - tracks selected - file-loaded arrives - track-list notification arrives - display logo if no video.
It needs to wait for property change notification instead of probing value immediately.
There was a problem hiding this comment.
But track-list notifications are sent when unloading files not just when loading them.
Going from a video to audio with
diff --git a/player/lua/osc.lua b/player/lua/osc.lua
index 58b4bd4429..89bf1ff54d 100644
--- a/player/lua/osc.lua
+++ b/player/lua/osc.lua
@@ -678,6 +678,7 @@ local function update_tracklist(_, track_list)
state.no_video = false
end
end
+ print('track-list notification - no_video = ' .. (state.no_video and 'true' or 'false'))
request_init()
end
@@ -2845,10 +2846,12 @@ mp.observe_property("idle-active", "bool", function(_, val)
end)
mp.register_event("file-loaded", function()
+ print('file-loaded')
state.file_loaded = true
request_tick()
end)
mp.add_hook("on_unload", 50, function()
+ print('on_unload')
state.file_loaded = false
request_tick()
end)`it logs
[osc] on_unload
[osc] track-list notification - no_video = true
[osc] track-list notification - no_video = true
[osc] file-loaded
[osc] track-list notification - no_video = true
There was a problem hiding this comment.
What if the new file does have video? I added that line to fix the logo flashing issue #17504 (comment).
There was a problem hiding this comment.
That was the first thing I tried. I am now able to reproduce the logo between videos but only with --no-config and even then rarely. I guess loading configured scripts slows file-loaded preventing tick() from being called before track-list's update.
Reuse the new track-list observer callback to check whether there is a video track.
cc65f5f to
020ad6f
Compare
Reuse the new track-list observer callback to check whether there is a video track.