Skip to content

Instantly share code, notes, and snippets.

@dsferruzza
Created June 8, 2014 21:12
Show Gist options
  • Save dsferruzza/2de8ec7bb71ab0406ba4 to your computer and use it in GitHub Desktop.
Save dsferruzza/2de8ec7bb71ab0406ba4 to your computer and use it in GitHub Desktop.
This is a Proof Of Concept of a feature I miss in VLC: "stop after this track"
--[[
This is a Proof Of Concept of a feature I miss in VLC: "stop after this track"
This is my first time hacking VLC, so I have some questions:
1) Is "descriptor().description" useful? (I can't find how it is used by VLC)
2) When is "meta_changed()" called and what is it supposed to return?
3) Is there a VLC Lua API's documentation? (I read https://www.videolan.org/developers/vlc/share/lua/README.txt but I had to pick up some stuff from existing extensions on GitHub to get this done)
4) Is there a "standard" way to handle localization?
5) Is it possible to add an entry to the tray icon's context menu? (How?)
]]
function descriptor()
return {
title = "Stop after this track",
version = "1.0.0-alpha",
author = "David Sferruzza",
shortdesc = "Allows you to tell VLC that you want to stop when the current track is over",
description = "Allows you to tell VLC that you want to stop when the current track is over", -- Is this really useful?
capabilities = {"input-listener"},
url = "https://github.com/dsferruzza",
}
end
function dbg(m)
vlc.msg.dbg("[" .. descriptor().title .. "] " .. m)
end
function activate()
if vlc.input.is_playing() then
dbg("Stopping after the current track")
vlc.osd.message("Stopping after the current track", nil, nil, 4 * 1000000)
else
dbg("Player is already stopped")
deactivate()
end
end
function deactivate()
vlc.deactivate()
end
-- I'm not really sure what is the point of that, but I get an error if it's not there
function meta_changed()
return false
end
-- This will be triggered when the extension is activated and the current track changes
function input_changed()
dbg("Stopping")
vlc.playlist.stop()
deactivate()
end
@ynikitenko
Copy link

Seems it doesn't work.
I copy this script to vlc extensions, start vlc and play a track, meanwhile I call lua stop-after-this-track.lua, but nothing changed after the end (the next played, as before).
The script gave no output, the return code was 0 (which is normal return in bash).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment