webcam access in website using silverlight

Hello friends,
Microsoft Silverlight 4.0 provided another great feature of Audio & Video capturing. Today I am interested in using one of these cool features which is video capturing.
With the help of the video & audio capturing feature we can get all the capturing devices and use them. In current example there is only one source which is my laptop webcam.

So we are using 8 simple steps. With the help this simple we are capable of capturing webcam and stop capturing.
Step 1:- Create a new project of Silverlight with version Silverlight 4 version.
Step 2:- Draw a shape either rectangle or eclipse. The shape will hold the video.
Step 3:-  CaptureDeviceConfiguration provides GetAvailableVideoCaptureDevice &   GetDefaultvideoCaptureDevice methods.
The GetAvailableVideoCaptureDevice list out the entire available video capture device attached with your machine and GetDefaultVideoCaptureDevice provides default video capture device.

But before accessing any device from any machine we need to request device access and need to determine whether the device access is allowed or not. For determining the permission or request a device access we have following 2 methods
CaptureDeviceConfiguration.AllowedDeviceAccess   CaptureDeviceConfiguration.RequestDeviceAccess

silverlight permissions
It will prompt message for accessing the capturing device when you run the program.

   var webCam = CaptureDeviceConfiguration.GetDefaultVideoCaptureDevice();

Step 4:-
            Once you determine the capture device configuration then you need to assign it to assign as a video capture source device of capturesource.
  captureSource = new CaptureSource();
Step 5:- Once you assign the capture source’s video capture device then use a new brush utility provided by Silverlight which is Video Brush.  You just need to set source of video Brush which will be your capture source.
  var videoBrush = new VideoBrush();

Step 6:- Once the video Brush’s source is set then you can fill any shape with video brush.
          rectangle1.Fill = videoBrush;
     ellipse1.Fill = videoBrush;

Step 7:- now to start capturing from video source you need to call start method of capture source.

Step 8:- you can stop capturing video by stop method.

 From the above description you can capture video from Webcam or any other video device which attached with your machine using Silverlight video capture facility. One more advantage is that you can take image also means image capturing is also possible. For this you have to define asynchronous image capture event.

silverlight 4.0

In this way you can access video capture device.  More than this you can download code from

Enjoy Silverlight.
Thanks & Regards
Rajat  Jaiswal

One thought on “webcam access in website using silverlight

  1. Thanks Sir for this useful information.
    I am working on the same type of project.In this project i have to start webcam through
    but i have “Microsoft Visual Studio 2008”.so plz can u help me.
    i m a trainee…
    So plz plz help me..
    my email address is “”

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.