Workaround a VLC Lua bridge bug.
New here? Learn about Bountify and follow @bountify to get notified of new bounties! x

The ticket linked above in VLC is a problem with their Lua sub system, the event in question should be fired when the metadata changes, and Lua scripts can be notified.

The intention here is to allow Lua language playlist providers to, for example, search for new content when.

The problem appears to be that the playlist change (meta change) callbacks are fired many, many hundreds of times too often.

Acceptable solutions:

  • A patch to VLC that fixes this on all/any platforms. The problems with this are numerous, not least the glacial VLC release cycle, and that the core team have little or no interest in the Lua functionality in VLC.
  • An effective debounce script in Lua. My intention is to post information upstream to an API when there are playlist item changes, this API then modifies the VLC playlist accordingly. The API could of course de-bounce inputs, but the client is the best place to do this. In line with the VLC Lua environment, I would like to be able to ignore repeated input, effectively doing nothing if the input hasn't changed. I believe this would hang from some fields in the playlist item, here's what I have so far:

(Note: Apparently code-formatting on this code-bounty platform doesn't work, here is the sample code as a Gist)

function input_changed()
  vlc.msg.warn("Input Changed!")
  -- local current_filename = get_current_filename()
  -- lc.msg.warn("Input Is: " .. current_filename)
end

--
-- Get the current playing item
--
function get_current_filename()
  vlc.msg.warn("Getting Current Filename...")
  local item               = vlc.input.item()
  local item_name_or_title = item:name()
  --
  -- Name is nil...
  --
  if item_name_or_title ~= nil then
    vlc.msg.warn("item.name() name was nil, checking metas...")
    --
    -- Try asking for the meta data
    --
    local item_metas = item:metas()
    --
    -- We'll take the title, if it exists
    --
    if item_metasthen
      vlc.msg.warn("present.. using that")
      item_name_or_title = item_metas
    end  
  end
  --
  -- Either the name or title..
  --
  vlc.msg.warn("Current item name is: " .. item_name_or_title)
  return sanitize(item_name_or_title)
end

There is more to the code than this, but that's effectively what I am dealing with. The input changed

awarded to Wikimedia
Tags
c
vlc
lua

Crowdsource coding tasks.

0 Solutions