Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6560807
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:30:33+00:00 2026-05-25T13:30:33+00:00

I’m trying to make a VLC script that checks if the "random" button is

  • 0

I’m trying to make a VLC script that checks if the "random" button is on, and if so when it jumps to a random file, instead of starting at time=0, it starts at a random time.

So far, it’s looking to me like it should be a playlist script and I can get the duration from the playlist object, but in this documentation page doesn’t show how to jump to a specific time from within the Lua script.

How can that be done in Lua?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T13:30:34+00:00Added an answer on May 25, 2026 at 1:30 pm

    Actually, the documentation does say you can do it…though not in so many words. Here’s what it says about the interface for playlist parsers:

    VLC Lua playlist modules should define two functions:
       * probe(): returns true if we want to handle the playlist in this script
       * parse(): read the incoming data and return playlist item(s)
            Playlist items use the same format as that expected in the
            playlist.add() function (see general lua/README.txt)
    

    If you follow through to the description of playlist.add() it says the items have a big list of fields you can provide. There are plenty of choices (.name, .title, .artist, etc.) But the only required one seems to be .path…which is “the item’s full path / URL”.

    There’s no explicit mention of where to seek, but one of the parameters you can choose to provide is .options, said to be “a list of VLC options. It gives fullscreen as an example. If a parallel to --fullscreen works, can other command-line options like --start-time and --stop-time work as well?

    On my system they do, and here’s the script!

    -- randomseek.lua
    --
    -- A compiled version of this file (.luac) should be put into the proper VLC
    -- playlist parsers directory for your system type.  See:
    --
    --   http://wiki.videolan.org/Documentation:Play_HowTo/Building_Lua_Playlist_Scripts
    --
    -- The file format is extremely simple and is merely alternating lines of
    -- filenames and durations, such as if you had a file "example.randomseek"
    -- it might contain:
    --
    --     foo.mp4
    --     3:04
    --     bar.mov
    --     10:20
    --
    -- It simply will seek to a random location in the file and play a random
    -- amount of the remaining time in the clip.
    
    function probe()
        -- seed the random number since other VLC lua plugins don't seem to
        math.randomseed(os.time())
    
        -- tell VLC we will handle anything ending in ".randomseek"
        return string.match(vlc.path, ".randomseek$")
    end
    
    function parse()
        -- VLC expects us to return a list of items, each item itself a list
        -- of properties
        playlist = {}
    
        -- I'll assume a well formed input file but obviously you should do
        -- error checking if writing something real
        while true do
           playlist_item = {}
    
           line = vlc.readline()
           if line == nil then
               break --error handling goes here
           end
    
           playlist_item.path = line
    
           line = vlc.readline()
           if line == nil then
               break --error handling goes here
           end
    
           for _min, _sec in string.gmatch( line, "(%d*):(%d*)" )
               do
                   duration = 60 * _min + _sec
               end
    
           -- math.random with integer argument returns an integer between
           -- one and the number passed in inclusive, VLC uses zero based times
           start_time = math.random(duration) - 1
           stop_time = math.random(start_time, duration - 1)
    
           -- give the viewer a hint of how long the clip will take
           playlist_item.duration = stop_time - start_time
    
           -- a playlist item has another list inside of it of options
           playlist_item.options = {}
           table.insert(playlist_item.options, "start-time="..tostring(start_time))
           table.insert(playlist_item.options, "stop-time="..tostring(stop_time))
           table.insert(playlist_item.options, "fullscreen")
    
           -- add the item to the playlist
           table.insert( playlist, playlist_item )
        end
    
        return playlist
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to create an if statement in PHP that prevents a single post
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.