Код захвата веб-камеры ниже:
Dim capturesource As New CaptureSource
' Get the default video capture device
Dim _videoCaptureDevice As VideoCaptureDevice = CaptureDeviceConfiguration.GetDefaultVideoCaptureDevice()
Dim _AudioCaptureDevice As AudioCaptureDevice = CaptureDeviceConfiguration.GetDefaultAudioCaptureDevice()
'Dim activeFile As New IsolatedStorageFile
Dim _isf As IsolatedStorageFile
Public Sub New()
InitializeComponent()
AddHandler capturesource.CaptureImageCompleted, AddressOf CaptureImageCompleted
End Sub
Private Sub VideoCapture_Loaded(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles Me.Loaded
If _videoCaptureDevice Is Nothing Then
btnPlayCapture.IsEnabled = False
btnStopCapture.IsEnabled = False
btnCaptureDevice.IsEnabled = True
MessageBox.Show("You don't have any default capture device")
Else
btnPlayCapture.IsEnabled = False
btnStopCapture.IsEnabled = True
'Set the Capture Source to the VideoBrush of the rectangle
'capturesource.Start()
capturesource.VideoCaptureDevice = _videoCaptureDevice
capturesource.AudioCaptureDevice = _AudioCaptureDevice
Dim videoBrush As New VideoBrush()
videoBrush.SetSource(capturesource)
rectWebCamView.Fill = videoBrush
If CaptureDeviceConfiguration.AllowedDeviceAccess OrElse CaptureDeviceConfiguration.RequestDeviceAccess() Then
btnPlayCapture.IsEnabled = True
btnStopCapture.IsEnabled = False
btnCaptureDevice.IsEnabled = False
End If
End If
End Sub
Private Sub btnPlayCapture_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles btnPlayCapture.Click
If Not capturesource.State = CaptureState.Started Then
capturesource.Start()
End If
btnPlayCapture.IsEnabled = False
btnStopCapture.IsEnabled = True
End Sub
Private Sub btnStopCapture_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles btnStopCapture.Click
capturesource.Stop()
btnPlayCapture.IsEnabled = True
btnStopCapture.IsEnabled = False
End Sub
Public Sub CaptureImageCompleted(ByVal sender As System.Object, ByVal e As CaptureImageCompletedEventArgs)
capturesource.CaptureImageAsync()
Dim sfd As New SaveFileDialog()
If CBool(sfd.ShowDialog()) Then
'Dim sr As New StreamReader(e.Result)
'Dim str As String = sr.ReadToEnd()
'Dim sw As New StreamWriter(sfd.OpenFile())
'sw.Write(str)
End If
End Sub
У меня есть код захвата веб-камеры. его работа идеально. Но мне нужно сделать видео и сохранить на сервере. Мне нужен какой-то вариант или метод в Silverlight. Нахожу большую часть кода в сети
как:
Захват изображения - http://www.silverlight.net/learn/graphics/webcam-and-mic/webcams-%28silverlight-quickstart%29
Большинство блогов и сайтов ссылаются только на это:
http://mtaulty.com/CommunityServer/blogs/mike_taultys_blog/archive/2009/12/28/silverlight-4-yet-more-on-capturing-video-from-webcams.aspx
Это хороший код, но не будет работать и его сложно понять. Любой научит меня этому!
как сделать WEBCAM RECORD?
Как сохранить файл RECORD в определенном формате?