I have the following code which isn't working. My camUrl
link works if I load into Firefox and streams from my cam, but nothing is displayed in my picturebox at runtime. Any ideas why?
public Thread _camThread;
private string camUrl = "http://my-domain-ip:2080/videostream.cgi?user=admin&pwd=password";
public HttpWebRequest webReq;
public WebResponse webRes;
public Stream sr;
private void btnStart_Click(object sender, EventArgs e)
{
if (_camThread == null) _camThread = new Thread(new ThreadStart(RunCam));
_camThread.Start();
}
private void RunCam()
{
try
{
webReq = (HttpWebRequest)WebRequest.Create(camUrl);
webReq.AllowWriteStreamBuffering = true;
webReq.Timeout = 20000;
using (webRes = webReq.GetResponse())
{
while ((sr = webRes.GetResponseStream()) != null)
{
image.Image = Image.FromStream(sr);
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void btnStop_Click(object sender, EventArgs e)
{
if (_camThread.IsAlive)
{
_camThread.Abort();
_camThread = null;
}
}