Siliverlight 4.0视频简单实现
Siliverlight 4.0里面已经支持视频了,实现代码很简单:
代码
1 private void Rectangle_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
2 {
3 VideoCaptureDevice webcamera = CaptureDeviceConfiguration.GetDefaultVideoCaptureDevice();
4 if (CaptureDeviceConfiguration.RequestDeviceAccess())
5 {
6 CaptureSource cap = new CaptureSource();
7 cap.VideoCaptureDevice = webcamera;
8 VideoBrush videoBrush = new VideoBrush();
9 videoBrush.SetSource(cap);
10 videoBrush.Stretch = Stretch.UniformToFill;
11 cap.Start();
12 //填充到矩形框中
13 this.canmera.Fill = videoBrush;
14 }
15 }
2 {
3 VideoCaptureDevice webcamera = CaptureDeviceConfiguration.GetDefaultVideoCaptureDevice();
4 if (CaptureDeviceConfiguration.RequestDeviceAccess())
5 {
6 CaptureSource cap = new CaptureSource();
7 cap.VideoCaptureDevice = webcamera;
8 VideoBrush videoBrush = new VideoBrush();
9 videoBrush.SetSource(cap);
10 videoBrush.Stretch = Stretch.UniformToFill;
11 cap.Start();
12 //填充到矩形框中
13 this.canmera.Fill = videoBrush;
14 }
15 }