Skip to content

osc.lua: merge the current-tracks/video observer into track-list's#17562

Open
guidocella wants to merge 1 commit intompv-player:masterfrom
guidocella:osc-current-tracks
Open

osc.lua: merge the current-tracks/video observer into track-list's#17562
guidocella wants to merge 1 commit intompv-player:masterfrom
guidocella:osc-current-tracks

Conversation

@guidocella
Copy link
Copy Markdown
Contributor

Reuse the new track-list observer callback to check whether there is a video track.


mp.register_event("file-loaded", function()
state.file_loaded = true
state.no_video = mp.get_property_native("current-tracks/video") == nil
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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.

Copy link
Copy Markdown
Contributor

@na-na-hi na-na-hi Mar 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tracks always get deselected before loading a new file though.

Copy link
Copy Markdown
Contributor

@na-na-hi na-na-hi Mar 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if the new file does have video? I added that line to fix the logo flashing issue #17504 (comment).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants