FuryCell Posted July 17, 2008 Posted July 17, 2008 (edited) I've been doing a lot of gaming lately and like to listen to music. Now a lot of other media players use up massive CPU cycles which kind of sucks when your gaming on a 2ghz P4. So I turned to VLC. However,VLC seems to lack the ability to set global hotkeys so I could change tracks and such while in a full screen game. I then decided to see if it had a com interface so i could script it. I had trouble,as others have had. Luckily,there is a solution to VLCs lack of COM functionality. VLC provides an interface to its console commands over TCP. Here is a quick script to demonstrate it. expandcollapse popup#NoTrayIcon #include<File.au3> #include <GUIConstants.au3> #Region::: connect to vlc over tcp on localhost TCPStartUp() Global $Socket=TCPConnect("127.0.0.1",2150) If $Socket=-1 Then MsgBox(0,"Error","Failed to connect to VLC over tcp proctol on localhost.Is it running and set to listen for console commands on port 2150?") Exit EndIf #EndRegion #Region::: create and show GUI $Form = GUICreate("VLC Test", 350, 58, -1, -1) $ButtonPT = GUICtrlCreateButton("9", 8, 8, 105, 41, 0) GUICtrlSetFont(-1, 14, 400, 0, "Webdings") $ButtonS = GUICtrlCreateButton("<", 121, 8, 105, 41, 0) GUICtrlSetFont(-1, 14, 400, 0, "Webdings") $ButtonNT = GUICtrlCreateButton(":", 238, 8, 105, 41, 0) GUICtrlSetFont(-1, 14, 400, 0, "Webdings") GUISetState(@SW_SHOW) #EndRegion #Region::: msgloop While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $ButtonS TCPSend($Socket,"stop"&@CRLF) ;send stop command over tcp Case $ButtonNT TCPSend($Socket,"next"&@CRLF) ;send next command over tcp Case $ButtonPT TCPSend($Socket,"prev"&@CRLF) ;send prev command over tcp EndSwitch WEnd #EndRegion For the example script to work you must set vlc to listen on 2150@localhost for console commands, and then click Add Interface>Console (See images for help) Also,the small script above is just barely scratching the surface is what is possible. Here is a list of commands that can be invoked. +----[ Remote control commands ] | | add XYZ . . . . . . . . . . add XYZ to playlist | enqueue XYZ . . . . . . . queue XYZ to playlist | playlist . . . show items currently in playlist | play . . . . . . . . . . . . . . . . play stream | stop . . . . . . . . . . . . . . . . stop stream | next . . . . . . . . . . . . next playlist item | prev . . . . . . . . . . previous playlist item | goto . . . . . . . . . . . . goto item at index | clear . . . . . . . . . . . clear the playlist | status . . . . . . . . . current playlist status | title [X] . . . . set/get title in current item | title_n . . . . . . next title in current item | title_p . . . . previous title in current item | chapter [X] . . set/get chapter in current item | chapter_n . . . . next chapter in current item | chapter_p . . previous chapter in current item | | seek X . seek in seconds, for instance `seek 12' | pause . . . . . . . . . . . . . . toggle pause | fastforward . . . . . . . set to maximum rate | rewind . . . . . . . . . . set to minimum rate | faster . . . . . . . . faster playing of stream | slower . . . . . . . . slower playing of stream | normal . . . . . . . . normal playing of stream | f [on|off] . . . . . . . . . . toggle fullscreen | info . . . information about the current stream | get_time . . seconds elapsed since stream's beginning | is_playing . . 1 if a stream plays, 0 otherwise | get_title . . . the title of the current stream | get_length . . the length of the current stream | | volume [X] . . . . . . . . set/get audio volume | volup [X] . . . . . raise audio volume X steps | voldown [X] . . . . lower audio volume X steps | adev [X] . . . . . . . . . set/get audio device | achan [X]. . . . . . . . set/get audio channels | atrack [X] . . . . . . . . . set/get audio track | vtrack [X] . . . . . . . . . set/get video track | vratio [X] . . . . . set/get video aspect ratio | vcrop [X] . . . . . . . . . set/get video crop | vzoom [X] . . . . . . . . . set/get video zoom | strack [X] . . . . . . . set/get subtitles track | menu [on|off|up|down|left|right|select] use menu | | help . . . . . . . . . . . . . this help message | longhelp . . . . . . . . . a longer help message | logout . . . . . exit (if in socket connection) | quit . . . . . . . . . . . . . . . . . quit vlc | +----[ end of help ] Hope this proves useful for some. muttley Edited July 17, 2008 by P5ych0Gigabyte HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code.
ptrex Posted July 18, 2008 Posted July 18, 2008 @P5ych0Gigabyte This is realy great !! I investigated the COM interface a while back, but didn't get far. Thanks for this nice tutorial. Regards ptrex, Contributions :Firewall Log Analyzer for XP - Creating COM objects without a need of DLL's - UPnP support in AU3Crystal Reports Viewer - PDFCreator in AutoIT - Duplicate File FinderSQLite3 Database functionality - USB Monitoring - Reading Excel using SQLRun Au3 as a Windows Service - File Monitor - Embedded Flash PlayerDynamic Functions - Control Panel Applets - Digital Signing Code - Excel Grid In AutoIT - Constants for Special Folders in WindowsRead data from Any Windows Edit Control - SOAP and Web Services in AutoIT - Barcode Printing Using PS - AU3 on LightTD WebserverMS LogParser SQL Engine in AutoIT - ImageMagick Image Processing - Converter @ Dec - Hex - Bin -Email Address Encoder - MSI Editor - SNMP - MIB ProtocolFinancial Functions UDF - Set ACL Permissions - Syntax HighLighter for AU3ADOR.RecordSet approach - Real OCR - HTTP Disk - PDF Reader Personal Worldclock - MS Indexing Engine - Printing ControlsGuiListView - Navigation (break the 4000 Limit barrier) - Registration Free COM DLL Distribution - Update - WinRM SMART Analysis - COM Object Browser - Excel PivotTable Object - VLC Media Player - Windows LogOnOff Gui -Extract Data from Outlook to Word & Excel - Analyze Event ID 4226 - DotNet Compiler Wrapper - Powershell_COM - New
FuryCell Posted July 18, 2008 Author Posted July 18, 2008 (edited) @P5ych0GigabyteThis is realy great !! I investigated the COM interface a while back, but didn't get far. Thanks for this nice tutorial.Regardsptrex,np. muttley I tried the com interface as well and it was frustrating as hell. This method seems to be a lot easier. Edited July 18, 2008 by P5ych0Gigabyte HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code.
Ibrahim Posted July 22, 2008 Posted July 22, 2008 truely nice work [font="Arial Black"]My Stuff[/font]UPnP Port Forwarding Final.GateWay InformationThe GateWay Watcher(detect speeofing)Rightclick Any file --->Hide/UnhideThe Tip WatcherA PanelShare WatcherThe Arp WatcherThe Online License Checker
system24 Posted January 6, 2009 Posted January 6, 2009 Nice. [center]It's a question of mind over matter, if I don't mind, it doesn't matter.[/center]
Bozzman Posted January 7, 2009 Posted January 7, 2009 expandcollapse popup#cs +----[ Remote control commands ] | | add XYZ . . . . . . . . . . add XYZ to playlist | enqueue XYZ . . . . . . . queue XYZ to playlist | playlist . . . show items currently in playlist | play . . . . . . . . . . . . . . . . play stream | stop . . . . . . . . . . . . . . . . stop stream | next . . . . . . . . . . . . next playlist item | prev . . . . . . . . . . previous playlist item | goto . . . . . . . . . . . . goto item at index | clear . . . . . . . . . . . clear the playlist | status . . . . . . . . . current playlist status | title [X] . . . . set/get title in current item | title_n . . . . . . next title in current item | title_p . . . . previous title in current item | chapter [X] . . set/get chapter in current item | chapter_n . . . . next chapter in current item | chapter_p . . previous chapter in current item | | seek X . seek in seconds, for instance `seek 12' | pause . . . . . . . . . . . . . . toggle pause | fastforward . . . . . . . set to maximum rate | rewind . . . . . . . . . . set to minimum rate | faster . . . . . . . . faster playing of stream | slower . . . . . . . . slower playing of stream | normal . . . . . . . . normal playing of stream | f [on|off] . . . . . . . . . . toggle fullscreen | info . . . information about the current stream | get_time . . seconds elapsed since stream's beginning | is_playing . . 1 if a stream plays, 0 otherwise | get_title . . . the title of the current stream | get_length . . the length of the current stream | | volume [X] . . . . . . . . set/get audio volume | volup [X] . . . . . raise audio volume X steps | voldown [X] . . . . lower audio volume X steps | adev [X] . . . . . . . . . set/get audio device | achan [X]. . . . . . . . set/get audio channels | atrack [X] . . . . . . . . . set/get audio track | vtrack [X] . . . . . . . . . set/get video track | vratio [X] . . . . . set/get video aspect ratio | vcrop [X] . . . . . . . . . set/get video crop | vzoom [X] . . . . . . . . . set/get video zoom | strack [X] . . . . . . . set/get subtitles track | menu [on|off|up|down|left|right|select] use menu | | help . . . . . . . . . . . . . this help message | longhelp . . . . . . . . . a longer help message | logout . . . . . exit (if in socket connection) | quit . . . . . . . . . . . . . . . . . quit vlc | +----[ end of help ] #ce #include "file.au3" $vlcconfigfile = @AppDataDir&"\vlc\vlcrc" $listen = " " Opt("tcptimeout",500) ;Write correct settings to config file. $vlcfile = FileOpen($vlcconfigfile,1) _FileWriteToLine($vlcconfigfile,2529,"rc-host=127.0.0.1:2150",1);hostname and port _FileWriteToLine($vlcconfigfile,2526,"rc-quiet=1",1);use quiet mode FileClose($vlcfile) ;Run VLC Media Player and opens console $vlcexe = Run(@ProgramFilesDir&"\VideoLAN\VLC\vlc.exe --extraintf rc") Sleep(1500);Gives some time to start VLC ;Connect to VLC console TCPStartup() Global $vlcmp=TCPConnect("127.0.0.1",2150) If $vlcmp=-1 Then MsgBox(0,"Error","Connecting error.") Exit EndIf ;Main Loop While 1 $input = InputBox("VLC Console writer",$listen);Use above CMD list or "exit" If $input = "exit" Then OnAutoItExit() Else _SendData($input) EndIf WEnd Func _SendData($command) If $vlcmp = -1 Then;Checks if connected else gives error code see help file TCPConnect MsgBox(0,"",$vlcmp) Else TCPSend($vlcmp,$command&@CRLF);Send data to console $listen = TCPRecv($vlcmp,4096);Check if it gets someting back and shows it in inputbox Return $listen EndIf EndFunc;=> _SendData() Func OnAutoItExit() ; TCPSend($vlcmp,"logout"&@CRLF) ; TCPSend($vlcmp,"quit"&@CRLF) TCPShutdown() Exit EndFunc;=> OnAutoItExit() I made this out of it who can test it for me:P i want to make it with hotkeys for in full screen apps like the TS said
Techone Posted July 10, 2015 Posted July 10, 2015 one question,all of the controls is being done via localhost, is there a way to control VLC from outside the PC.i have tried using Docklight, but i cant ever connect to VLC. is it a Windows thing?
TheDcoder Posted July 10, 2015 Posted July 10, 2015 (edited) @Techone Welcome to AutoIt forums! This thread is almost 6 years old, so most of the script would be broken (I didn't test) also there is an chance that VLC has changed/removed the functionality you are looking for.... I recommend to look for an other solution. If you would still like to do that using this script then: Assuming that the script is working, you can replace 127.0.0.1 with the IP of the remote computer. TD Edited July 10, 2015 by TheDcoder Welcome EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion
argumentum Posted July 19, 2015 Posted July 19, 2015 for the next one looking to make this work.When you start vlc you'll need the next command line:vlc.exe --extraintf rc --rc-host localhost:2150for more info read the vlc wiki ( https://wiki.videolan.org/Documentation:Advanced_Use_of_VLC/#Modules_selection ). Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now