1.

Solve : Play Random Video from List?

Answer»

So I have a bunch of movies that I legally own, and currently I have to navigate and select a specific file to watch. I was wondering if anyone had any suggestions of tools out there that allow for this?

I was thinking of a way to do this with some custom programming, but was thinking someone out there must have already created a method to do this and probably far better than a program that I would draft up to accomplish this. But... I am not finding any leads on google to a solution that is a definite working method. Closest I found was this: http://forum.kodi.tv/showthread.php?tid=126418

If I were to create a program to accomplish this, I would simply place all the video files into a single flat directory, and then have a function read in from DIR and then with use of a random generator which is populated by the number of files that exist in this directory, pick a number from say 1 to 208 and say it PICKS 117, and then it launches the video file with a start instruction for VLC.exe "VideoFiletoPlay.MP4" in which VideoFiletoPlay.MP4 is the 117th file listed on the Directory ( DIR ) list alphanumerically.

But before I take the time to possibly REINVENT the wheel, I figured I'd ask around first.

I ditched cable TV and own a bunch of movies and tv show collections that I bought full seasons of on DVD etc, and the one thing I miss about cable TV is simply turning on the tv and the randomness of what I will find channel surfing. If i had a single video channel with some randomness in it which a choice to skip to the next random show or movie that would be awesome vs having to scroll through and make decisions on what i want to watch from many directories and which shows in seasoned shows to watch etc since I generally dont have enough time to watch a complete season of any show from beginning to finish but just want to watch something random for 45 MINUTES etc.  Good idea.
Rather that manipulate the order of the files in a directory, just use a playlist.
You can do  this. Create a playlist in your favorite media player.
Use a pair of dice to pick a number.
Quote

Create a playlist in your favorite media player.
Use a pair of dice to pick a number.

Curious as to how you can pass an instruction from say a C++ or batch instruction to the media player to tell it to play a specific number from list though?     Unless there are some switches to add beyond say ( media player - "file to open and play" ) such as VLC.exe "PlayThisVideo.MP4", it will only play the specific video file called upon. So I was thinking that if the DIR output was passed to a text file and the random generator read in a specific line in relation to the random number it comes up with from the DIR command which shows the number of files at the bottom of the listing, that was a way to know the parameters of which to stay within for a random number generated and so a number generated could reference to a line that the file is listed on in alphanumeric sequence.

Is there a media player that can handle MP4 or AVI playlist from command from cmd shell that you know of which could take in a random value passed to it?You may want to read this. You can edit a playlist in C++ and submit it to WMP.
https://code.msdn.microsoft.com/windowsapps/Playlist-sample-3d80daee
Applies to Windows 8.1 and you can still get a free evaluation.hmm interesting.... going to dig further into the content you provided. I wasnt aware of microsoft offering these code EXAMPLES etc.I was using Music files but this should ALSO work for Video files. You may need to change some of the properties, and of course you'll probably need to tweak or remove things like the MsgBox, but this should get you started with a VBScript solution, I think.

-You'll want to change the file extension. I was having it play .FLAC music files. Obviously you'll want .AVI or other file types. You'd need to change the If appropriately.
-Naturally you'll want to change the folder as well.
-Right now it will show a messagebox and when you press OK it will change the file Windows Media Player is playing to a new random file. If you press cancel the script exits (and quits the Media player instance). I imagine some of that may need revision as well. It could also be revised to work recursively I suppose but that was too much of a PITA for me to justify doing as part of a first pass


Code: [Select]Dim WMP
Dim FSO
Dim DirGrab
Dim iterateFile
Dim FileListing
Dim ChosenFile
Set FSO = CreateObject("Scripting.FileSystemObject")
Set DirGrab = FSO.GetFolder("Path\To\Folder")
Redim FileListing(0)
Dim Count
Count=0
For Each iterateFile in DirGrab.Files
    grabExtension = Right(iterateFile.Name,InstrRev(iterateFile.Name,"."))
    if(StrComp(grabExtension,".flac",1)) Then
        Redim Preserve FileListing(Count)
        FileListing(Count)=iterateFile.Path
        Count=Count+1
    End If
Next

Continue=true
Set WMP = CreateObject("WMPlayer.OCX.7")
Do While Continue

ChosenFile = FileListing(Int(Rnd*Count))

   With WMP  ' saves typing
     .settings.autoStart = True
     .settings.volume = 50  ' 0 - 100
     .settings.balance = 0  ' -100 to 100
     .settings.enableErrorDialogs = False
     .enableContextMenu = False
     '.URL = ChosenFile
     .OpenPlayer(ChosenFile)
   End With
   Continue = MsgBox("Press OK to shuffle and play a new track. Press Cancel to Exit.",1+64)=1
Loop
Set WMP = nothing
WScript.Quit


Discussion

No Comment Found