last day (14 days later) » 

01:06
1
A: How can I write a plugin for VLC that responds to play, pause and stop events?

approxiblue I'm using VLC 2.2.1 on Windows. Here's a simple Lua plugin that recognizes play/pause/stop events: function descriptor() return { title = "VLC Dummy Extension", capabilities = { "playing-listener" } } end function activate() end function deactivate() end function meta_changed()...

Awesome answer! Thank you! Is there any way to run these extensions with VLC on the command line? I've read that it isn't possible to load an extension from the command line (stackoverflow.com/questions/29047899/…), but I'm wondering if there's a way to do it roundabout... load an interface (which is loadable via -I luaintf --lua-intf="someinterface") which then loads the extension that reports metadata via HTTP? Also, is there a list of the fields available on item? I really need the URI.
@Brad You can get the URI: item::uri(). Here's the list of all methods on vlc.input.item(). Looking into interfaces...
@Brad You can't unfortunately. To load an extension, VLC has to set up a thread, an event loop, then register Lua hooks so they get updates from the VLC core. This happens in C. When loading an interface, VLC doesn't do any of that, and you can't from a Lua interface script either.
@Brad An interface is passive from what I've seen. You won't get events from VLC core. There used to be vlc.var.add_callback and vlc.var.del_callback (2.0+ versions) which let you listen to any core events from an extension, but they were deemed unstable and removed in later versions. Some old addons are affected (logs in comments say these functions disappear in 2.1).
Thank you very much for this information. I'll award the bounty as soon as Stack Overflow lets me. For my use case, I need to run cvlc and have VLC hit an HTTP server with track updates. I think that since I cannot load an extension directly, I'll have to use the metadata fetching Lua script method. I have this working... it's hacky but sort of works. Thanks again for all of your help! It's too bad the scrobbler URL config parameter on the last.fm plugin doesn't work correctly... I could just use that directly.
@Brad Thanks. Is your metadata fetching script an extension, an interface or something else?
I can't use an extension because there is seemingly no way to load it on the command line. I was hoping to make an interface which I can easily load on the command line, but there is seemingly no way to get events for when the track changes using the interface API. (Please correct me if I'm wrong on that.) So what I've done is put a script in lua/meta/fetcher that implements fetch_ meta(). When a new track is played, this is called and I can infer in my script that a track is playing. (Hopefully VLC never tries to use it to get metadata at other times.)
01:07
Good idea. You can definitely do that, I think VLC expects people to add more fetchers if they want anyway.
It seems to work fine...

```
function descriptor()
return { scope="local" }
end

function fetch_meta()
local metas = vlc.item:metas()

vlc.msg.info(metas["filename"])
end
```
> Available VLC specific Lua modules: msg, stream, strings, variables, item,
objects and xml. See lua/README.txt
Right... that's the problem... not sure how to do HTTP requests from there.
They seem to imply it's possible however. It can be either a "local" or "network" script... so if network, I'm not sure how that'd work without net.
At this point, I'm near executing VLC via Node.js and parsing the STDERR stream to figure out what VLC is playing. :-)
oh lol
[0x7fa940000958] main input debug: http://api.radioreddit.com/tracks/7495/media/original?.mp3' successfully opened`
01:10
Yeah, log your unique messages, and... hey, it works.
Fortunately the messages I need are already there. I just need to write some regex for parsing. At this point, I think that's what I'm going to have to do, ha.
Unless you know how I can make an HTTP request from a metadata script?
You can't, they don't even give you net.
The fetcher scripts are supposed to be fast
you return the path and let VLC core handle IO efficiently.
I wonder why they bother with the "network" descriptor value then.
No idea.
Any way I could return a URL to force VLC to hit it, even with a GET request? Album art or something?
01:13
That's possible.
Yes.
function fetch_meta()
return "http://example.com/myscript?item=" + vlc.item:uri()
end
or something like that
Who says the URL has to be valid lol
Ha, well I could even return something valid. I control the API I need to hit.
You should write all this down in another post.
For context, I'm working on the stream source for RadioReddit.com. We have 8 genre-based streams. I have my own internet radio company, AudioPump, Inc., and Radio Reddit and many of my other customers are fed up with Liquidsoap. So, we're trying an experiment to see how viable VLC is for a stream source. The streams work fine, but the big catch is that metadata doesn't work. The shout sout plugin doesn't support updating metadata unless you're using the Ogg muxer.
So, I'm trying to hack around the problem.
I think for now I'll just make a Node.js supervisor for VLC.
01:18
Good luck!
Thanks, and thanks again for all of your help.
Thanks for the cool problem.

last day (14 days later) »