Talespin_Kit
Talespin_Kit

Reputation: 21877

How to get the current playing time in vlc Lua extension script

I am new writing lua extension for vlc. I have a bare minimal vlc extension that pops a dialog on activating the menu item and logs message to terminal. How to get the current duration of the file which is playing. Looked at this manual https://www.videolan.org/developers/vlc/share/lua/README.txt but did not help.

Upvotes: 2

Views: 1748

Answers (2)

Tee
Tee

Reputation: 424

You could try using the time VLC variable

such as:

function getTimePassed()
    return vlc.var.get(vlc.object.input(), "time")
end

And then use it as:

local elapsedDuration = getTimePassed()
local timeAsString = os.date("%H:%M:%S", elapsedDuration)

Upvotes: 4

Paul Kulchenko
Paul Kulchenko

Reputation: 26754

From the documentation you referenced:

input.item(): Get the current input item. Input item methods are:
  :duration(): Get item's duration in seconds or negative value if unavailable.

So, input.item():duration() should give you the duration you are looking for.

Upvotes: 0

Related Questions