Skip to content

Commit

Permalink
fix bug from 023c687, album art is shown again
Browse files Browse the repository at this point in the history
christoph-heinrich authored and mfcc64 committed Jun 14, 2022
1 parent d696a39 commit 42c379e
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions visualizer.lua
Original file line number Diff line number Diff line change
@@ -255,7 +255,14 @@ local function get_visualizer(name, quality, vtrack)
"mode = p2p," ..
"format = rgb0 [vo]"
elseif name == "off" then
if vtrack ~= nil then
local hasvideo = false
for id, track in ipairs(mp.get_property_native("track-list")) do
if track.type == "video" then
hasvideo = true
break
end
end
if hasvideo then
return "[aid1] asetpts=PTS [ao]; [vid1] setpts=PTS [vo]"
else
return "[aid1] asetpts=PTS [ao];" ..
@@ -291,17 +298,24 @@ local function select_visualizer(vtrack)
return ""
end

local current_visualizer = ""
local function visualizer_hook()
local count = mp.get_property_number("track-list/count", -1)
msg.info("visualizer_hook " .. count)
if count <= 0 then
return
end

local atrack = mp.get_property_native("current-tracks/audio")
local vtrack = mp.get_property_native("current-tracks/video")

mp.set_property("options/lavfi-complex", select_visualizer(vtrack))
--prevent endless loop
if current_visualizer ~= opts.name then
local lavfi = select_visualizer(vtrack)
if lavfi ~= "" then
current_visualizer = opts.name
end
mp.set_property("options/lavfi-complex", lavfi)
end
end
mp.observe_property("current-tracks/audio", "native", function(name, value) visualizer_hook() end )
mp.observe_property("current-tracks/video", "native", function(name, value) visualizer_hook() end )

0 comments on commit 42c379e

Please sign in to comment.