Code: Select all
...
if state==4 then
vlc.playlist.goto( id )
...
Exactly, couldn't have said it better myself.So you do not need to see the random order. You just need to play playlist items in random order, each item only once, then new randomization after all items were already played. Just better/proper Random with Loop all. Right?
Code: Select all
From some simple scripting languages (and general bullshit) I've used I would do something like:
$totalfiles = all videos in playlist.
$file = current file (video about to be played).
$playedfiles = all videos that have been played once and stored.
$totalnumber = Total Number of Files (assigned a number) in playlist.
$playednumber = Total Number of Files that have been played.
#MENU
Insert Code to build menu with options that are applicable to this extension.
#BEGIN
Open playlist.xspf
*Insert Code For Randomizing the files in this list* (ie: Something using the RNG)
Save playlist.xspf > randomplaylist.xspf
$totalnumber = findstr /R /N "^" randomplaylist | find /C ":"
GOTO #FILE_CHECK
#FILE_CHECK
If $file != $playedfiles
THEN
GOTO #FILE_VIDEO_PLAY
ELSE
GOTO #NEXT_FILE
ENDIF
#NEXT_FILE
IF $playednumber = totalnumber
GOTO #BEGIN
ELSE
Open randomplaylist.xspf
Select.Next.File // Code to open the randomly generated playlist file and select the next file on the list.
$file = Next.File // Setting variable of the selected next filename.
CALL #FILE_CHECK
#FILE_VIDEO_PLAY
Play filename // The action of playing the file (video)
$playednumber = $playednumber + 1 // To set variable adding 1, so once it reaches the total $playednumber it starts the process all over.
GOTO #NEXTFILE
Thanks! I will be testing and if any issues, or non issues I will report back.Here is another attempt:INSTRUCTIONS:Code: Select all
-- "New Random with Loop all.lua" -- VLC Extension first_ID = 6 items = 10 random_order={3,5,8,2,9,4,7,1,10,6} function descriptor() return { title = "New Random with Loop all", capabilities = {"input-listener", "meta-listener"} } end function activate() create_dialog() end function deactivate() end function close() vlc.deactivate() end k=0 function input_changed() state = vlc.var.get(vlc.object.input(), "state") --vlc.msg.info("["..descriptor().title.."] Input state = "..state) if state==4 then k=k+1 if k>#random_order then k=1 New_Random() end vlc.playlist.goto(random_order[k]+first_ID-2) --vlc.msg.info("["..descriptor().title.."] ".. k ": goto(" .. random_order[k] .. "+"..first_ID.."-2)") order="" for ix, vx in ipairs(random_order) do if ix==k then vx="<b>["..vx.."]</b>" end order=order..vx..", " end w8:set_text(order) w:update() end end function meta_changed() end ----- Dialog box: ----- function create_dialog() w = vlc.dialog(descriptor().title) w1 = w:add_label("ID of the first item:", 1, 1) w2 = w:add_text_input(first_ID, 2, 1) w3 = w:add_button("Check ID:",click_CheckID, 3, 1) w4 = w:add_label("Number of items:", 1, 2) w5 = w:add_text_input(items, 2, 2) w6 = w:add_label("Random order", 1, 3, 2) w7 = w:add_button("START",click_Start, 3, 3) w8 = w:add_html("", 1, 4, 3) end function click_CheckID() w3:set_text("Check ID: " .. vlc.playlist.current()) end function click_Start() k=0 -- playback reset New_Random() order = "" for _, v in ipairs(random_order) do order = order..v..", " end w8:set_text(order) end ----- Generator of random order: ----- i=0 function New_Random() i=i+1 first_ID = w2:get_text() items = w5:get_text() random_order = {} for j=1,items do random_order[j] = j end -- Initialize the pseudo random number generator math.randomseed( os.time() ) math.random(); math.random(); math.random() -- done. :-) random_order = shuffle(random_order) w6:set_text("Random order #"..i) end function shuffle(t) local n = #t while n > 2 do -- n is now the last pertinent index local m = math.random(n) -- 1 <= m <= n -- Quick swap t[n], t[m] = t[m], t[n] n = n - 1 end return t end
* feed VLC playlist with files;
* VLC Random is off, Loop is off, start to play the first file;
* activate the extension in VLC menu;
* press [Check ID:] button;
* write the ID in the text input field (usually value 5 or 6);
* how many files are there in the playlist (you can activate ID column in VLC playlist (right-click on the header) in Detailed View);
* press [START] button;
* stop the playback of the first file in the playlist;
=> playback continues in random order
A new random order will be automatically generated at the end of the last file in current random order or you can press [START] button again anytime.
Starting VLC with --play-and-stop CLI parameter could help (desktop shortcut icon or batch file). Appropriate setting in VLC preferences: Tools > Preferences > ( Show settings = All ) > Playlist: [v] Play and stop >> Save changes, restart VLC.
You know more than me. So all you need is to learn Lua. It is not that difficult for everybody with some programming experience. "Getting started?" forum topic, necessary functions, VLC Lua Readme document, Lua 5.1 reference manual is really all you need.I know I output the 127.0.0.1/requests/status.xml through the built in HTTP VLC webserver ...
Return to “Scripting VLC in lua”
Users browsing this forum: No registered users and 2 guests