| 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? Create a playlist in your favorite media player. 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 |
|