PDA

View Full Version : Controlling my slimp3 with the multimedia keys on mykeyboard



Tim Long
2004-04-05, 07:32
If you happen to have Visual Studio .NET then there is full support in
the .NET framework for opening HTTP sessions without displaying a
browser window. The code you need goes something like this (in C#)...

--Tim Long



/// <summary>
/// Sends a command to the SLIMP3 web interface, and
returns the response. The command should not include any IP address or
FQDN. This is added automatically.
/// </summary>
private string SendCmd(string strCmd)
{
string strResponse = "Error";
try
{
string strWebCmd = "http://" +
m_strServer + "/" + strCmd;
Uri myUri =new Uri(strWebCmd);
// Create a new request to the above
mentioned URL.
WebRequest myWebRequest=
WebRequest.Create(myUri);
// Assign the response object of
'WebRequest' to a 'WebResponse' variable.
WebResponse myWebResponse =
myWebRequest.GetResponse();
Stream stmReply =
myWebResponse.GetResponseStream();
StreamReader sr = new
StreamReader(stmReply);
strResponse = sr.ReadLine();

}
catch (Exception ex)
{
Debug.WriteLine(ex);
}
return strResponse;
}

> -----Original Message-----
> From: discuss-bounces (AT) lists (DOT) slimdevices.com
> [mailto:discuss-bounces (AT) lists (DOT) slimdevices.com] On Behalf Of
> Jeff Shanholtz
> Sent: Monday 5 April 2004 05:27
> To: discuss (AT) lists (DOT) slimdevices.com
> Subject: [slim] Controlling my slimp3 with the multimedia
> keys on my keyboard
>
> I've got one of those MS Multimedia keyboards that's got
> play/pause, stop, prev, and next buttons on it. It would be
> really cool if I could have them perform those commands on my
> slimp3 (the keyboard allows you to configure the keys to run
> arbitrary commands). Unfortunately this is complicated
> slightly by the fact that this keyboard is on a windows
> machine and the slimserver software is on a linux machine.
>
> I could just have them execute an http link that I can get
> from the slimserver web interface, but I'd really prefer to
> avoid having it launch a browser window to accomplish the
> task. Is there any solution for doing this currently?
> Alternatively, if it's not too complicated a task, I could
> program it in perl or c++ if someone could point me to the
> information I would need (or perhaps if there's no current
> solution I'll take this to the dev group).
>
> If anyone could provide some insight on this I would appreciate it!
>
>