Firstly I'd like to say hi to all the members of this forum. I'm fairly new to coding with Media Studio but seem to be bumbling through okay apart from this one problem that I hope someone can help me with.
Using the following code on a button the listbox is populated with various media files, and that works perfectly:
And then this code on the listbox plays any media file clicked, displaying it in the video object:
What i would like to do is be able to shuffle, or randomize the media files either on loading or by use of another button that the user clicked.
I have searched the forums and did find some code that randomized on load, but the folder had to be pre-selected as opposed to browsing a computer and choosing the folder via file explorer.
Any help would be much appreciated.
Using the following code on a button the listbox is populated with various media files, and that works perfectly:
Code:
--Disable listbox Updating ListBox.SetUpdate("ListBox1", false); --Get the desired folder to browse folder = Dialog.FolderBrowse("Open Folder", "C:\\"); --populate tables with all the .mp4 and .mpg files file_mp4 = File.Find(folder, "*.mp4", false, false, nil); file_mpg = File.Find(folder, "*.mpg", false, false, nil); video = {file_mp4, file_mpg}; --do the following for each file: for k in pairs(video) do --loops through the different video types for j,file_path in pairs(video[k]) do --loops through each video file --add the item to the listbox, with the name visible and path as data ListBox.AddItem("ListBox1", String.SplitPath(file_path).Filename, file_path); end end --Allow the listbox to display the updated content ListBox.SetUpdate("ListBox1", true);
Code:
selected = ListBox.GetSelected("ListBox1"); for j,k in pairs(selected) do Video.Load("Video1", ListBox.GetItemData("ListBox1", k)); Video.Play("Video1"); end
I have searched the forums and did find some code that randomized on load, but the folder had to be pre-selected as opposed to browsing a computer and choosing the folder via file explorer.
Any help would be much appreciated.
Comment