Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I want to stream/Broadcast my Webcam Live to my Website,

I using Windows Hosting and the website is developed over ASP.Net

Please Guide , as i want to avoid using any Third Party
Posted

 
Share this answer
 
This video demonstrates exactly what you need: how to stream the image of USB webcams (and IP cameras as well) to website in C#[^]. The following code snippet shows how to connect to your USB webcam and display its image:


C#
private void ConnectUSBCamera_Click(object sender, RoutedEventArgs e)
{
_webCamera = WebCamera.GetDefaultDevice();
if (_webCamera == null) return;
_connector.Connect(_webCamera, _provider);
_videoSender = _webCamera;


_webCamera.Start();
_videoViewerWpf.Start();
}



And the code example below presents the implementation of the broadcasting. This solution is based on MJPEG streaming (Motion JPEG[^]):


C#
private void Start_Streaming_Click(object sender, RoutedEventArgs e)
{
var ip = ipAddressText.Text;
var port = PortText.Text;


_streamer = new MJPEGStreamer(ip, int.Parse(port));


_connector.Connect(_videoSender, _streamer.VideoChannel);


_streamer.ClientConnected += streamer_ClientConnected;
_streamer.ClientDisconnected += streamer_ClientDisconnected;


_streamer.Start();
}


void streamer_ClientConnected(object sender, Ozeki.VoIP.VoIPEventArgs<imjpegstreamclient> e)
{
e.Item.StartStreaming();
}


void streamer_ClientDisconnected(object sender, Ozeki.VoIP.VoIPEventArgs<imjpegstreamclient> e)
{
e.Item.StopStreaming();
}


private void Stop_Streaming_Click(object sender, RoutedEventArgs e)
{
_streamer.Stop();
_connector.Disconnect(_videoSender, _streamer.VideoChannel);
}</imjpegstreamclient></imjpegstreamclient>



If you are interested in this solution, I encourage you try out the example program that can be found next to the previously mentioned video and it comes with free source code.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900