【发布时间】:2018-11-07 09:22:23
【问题描述】:
我想在我的表单中添加一个按钮,将“播放”命令发送到同一网络中的 vlc 播放器。 我正在使用此代码发送 http 请求:
private void VlcPlay_Click(object sender, EventArgs e)
{
String URI = "http://192.168.1.5:8080/requests/status.xml?command=pl_play";
WebClient webClient = new WebClient();
Stream stream = webClient.OpenRead(URI);
stream.Close();
}
问题在于 vlc 请求:username=blank + password="1234"(可以更改)。 - vlc 不允许设置用户名,它必须为空。 (愚蠢的) - vlc 不允许在没有“某些”密码的情况下进行连接。
我试过这样做:
private void VlcPlay_Click(object sender, EventArgs e)
{
String URI = "http://192.168.1.5:8080/requests/status.xml?command=pl_play";
WebClient webClient = new WebClient();
string credentials = Convert.ToBase64String(
Encoding.ASCII.GetBytes("" + ":" + "1234"));
webClient.Headers[HttpRequestHeader.Authorization] = string.Format("Basic {0}", credentials);
Stream stream = webClient.OpenRead(URI);
stream.Close();
}
没用。
我如何只发送没有用户名的密码? 谢谢
【问题讨论】: