Running the Application
To test your work, press F5 to run the application. You'll get a result similar to that shown in Figure 5, but differing according to the devices installed on your machine.
Figure 5 The application displays the lists of available audio and video devices.
Select your favorite microphone and webcam and then click Start. At this point, the application will ask for confirmation before starting the capture process, as shown in Figure 6.
Figure 6 Permissions request from the application.
Click Yes to grant permissions and continue, or click No if you don't want to start capturing. If you click Yes, after a few seconds you'll be able to see the result of the video source. Figure 7 shows an example coming from my webcam.
Figure 7 The application has started capturing.
When you want to capture a single frame, simply click Get Picture. Notice that each time you click a button, a thumbnail of the captured image is shown in the ListBox at the bottom of the interface. Remember that such a ListBox is data-bound to a collection of custom objects, each storing the image and the time stamp. Figure 8 shows an example of what I just described.
Figure 8 Showing captured images with time stamps.
Thus, the application is capturing correctly from audio and video sources. When you want to stop capturing, click the Stop button.
Of course, this application could be improved by adding recording capability or code for saving still images to isolated storage, but these functionalities are outside the scope of this article. Browse the code samples on the official Silverlight website for further examples and ideas. You can also find useful documentation from Microsoft about working with media devices in Silverlight 4: