dbraner Posted May 9, 2012 Share Posted May 9, 2012 (edited) Hi, i wrote an input plugin for DVBViewer for receiving remote commands via a tcp connection. The plugin listens on a specific tcp port for incoming commands. It supports DVBViewer input commands as well as execution of windows commands. The plugin is written in C/C++ based on the multimedia key plugin of erwin (thanks a lot erwin!). Source code is included. Attention! Please make sure that your local firewall doesn't block the network port! Installation: Unzip file NetworkKeys.zip and copy the files NetworkKeys.dll and NetworkKeys.ini into the DVBViewer Plugin folder. Start DVBViewer and activate plugin under Options -> Input -> Plugins. NetworkKeys.zip Configuration: You can adjust the following settings in the ini file: Port=Number - Specifies the network port for communication, default is 4567 ExecCmd=Number - Turns windows command execution on(1) or off(0), default is off(0) The zip file includes a sample client program (sendkey.exe) for sending commands to the plugin. You can use AutoIt as a command client or any other scripting language which supports tcp socket connections. Even building a Website to remote control your HTPC might be a nice idea (see PHP example below). Usage of the command client sendkey.exe: sendkey Server Port Command Server - IP-Address or name of machine where DVBViewer with NetworkKeys plugin is running. Port - The network port Command - The command to send Each command must begin with a prefix "c:" or "d:". The prefix c: tells the plugin to execute a windows command. The text after prefix d: will be send to DVBViewer as an input command. Commandline example: Start a command line window on your DVBViewer PC (executed on the same machine = 127.0.0.1 = localhost): sendkey 127.0.0.1 4567 "c:cmd.exe" Send a channellist command to DVBViewer: sendkey 127.0.0.1 4567 "d:channellist" Every command you send to DVBViewer must be configured in default.remote. This file is located in the DVBViewer configuration directory in folder Remotes. You can edit this file with notepad. For the previous channellist example the entry in default.remote is: <Command Name="Channellist" Value="7" ID="7" System="-1"> <Event Source="Keyboard">K</Event> <Event Source="Network Keys">Channellist</Event> </Command> Specifiy "Network Keys" as the event source. AutoIt example: Local $socket Local $port = 4567 If $CmdLine[0] <> 2 Then ConsoleWriteError ("Command line syntax error") Exit EndIf TCPStartup () $socket = TCPConnect ($CmdLine[1], $port) If $socket > 0 Then TCPSend ($socket, $CmdLine[2]); EndIf TCPCloseSocket ($socket) TCPShutdown () PHP example (for remote control of DVBViewer via website): The following PHP script should be called like test.php?command=d:channellist <?php // Substitute IP address by the address of PC where the plugin is installed $ipaddr = "192.168.1.55"; echo "Sending command ${_GET['command']} to $ipaddr\n"; $fp = fsockopen ($ipaddr, 4567, $errno, $errstr, 30); if (!$fp) { echo "$errstr ($errno)<br />\n"; } else { fwrite($fp, $_GET['command']); fclose($fp); } ?> Source Code for Visual Studio: NetworkKeysSrc.zip Edited May 11, 2012 by dbraner Quote Link to comment
VinoRosso Posted June 18, 2012 Share Posted June 18, 2012 Hi, könntest du das Plugin evtl so umbauen, dass man (auch) einfach action IDs an den viewer schicken kann? Dann könnte ich das für die Fernbedienung verwenden bisher verwende ich den httpserver, aber der zickt irgendwie rum nach standby/hibernate.... Plugin würde mir viel besser gefallen, das läuft immer wenn der DVBViewer läuft..... Oder ich machs selber, falls ich dazu die zeit finde (vor allem C zu lernen) ;-) Oder kann man jetzt schon action IDs senden? Quote Link to comment
dbraner Posted June 20, 2012 Author Share Posted June 20, 2012 Hi, könntest du das Plugin evtl so umbauen, dass man (auch) einfach action IDs an den viewer schicken kann? Sending action ids is not possible because it's an input plugin. (well, to be honest it's possible to implement this but then it's no longer an input plugin). But stay tuned. I'm working on a little program which I call "HTPC command server". This program will do what you want (and a lot more ...) Quote Link to comment
VinoRosso Posted June 20, 2012 Share Posted June 20, 2012 (edited) Sending action ids is not possible because it's an input plugin. (well, to be honest it's possible to implement this but then it's no longer an input plugin). But stay tuned. I'm working on a little program which I call "HTPC command server". This program will do what you want (and a lot more ...) Oh English forum, sorry :-) Nice, will your "command server" be a DVBViewer Plugin or a standalone application? Edited June 20, 2012 by VinoRosso Quote Link to comment
dbraner Posted June 20, 2012 Author Share Posted June 20, 2012 Nice, will your "command server" be a DVBViewer Plugin or a standalone application? My first idea was to build a plugin. But after thinking about the important functions for me i decided to implement it as a standalone application. I need a "command server" to access the HTPC and fix things even if DVBViewer is not responding. This is not possible with plugin. i.e. my wife calls me by phone and tells me that something is not working. In this case it's nice to connect remotely to the HTPC command server, execute Windows commands or check DVBViewer status. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.