i am working on a project and need to stream video through mvvm pattern.i got video in code behind.but i can't get video in mvvm pattern.
in xaml for button and image control :-
<Button Command="{Binding StartCommand}" Content="Start" Grid.Row="4" Height="38" Margin="9" Name="btnwebcamstart" Width="{StaticResource btnWidth}"/>
<Image Source="{Binding Source=Imagevideo}" Margin="9" Name="patientvideo" Stretch="Fill" Width="120" Grid.RowSpan="2" Height="104" Grid.Row="1" />
i just make one image property:
public Image Imagevideo
{
get
{
return imagevideo;
}
set
{
imagevideo = value;
OnPropertyChaged("Imagevideo");
}
}
WebCam is a .cs file .
in constructor i write:-
WebCam webcam=new webcam();
webcam.InitializeWebCam(ref Imagevideo);
this.StartCommand = new DelegateCommand<object>(this.patientvideostart);
}
public void InitializeWebCam(ref System.Windows.Controls.Image ImageControl)
{
webcam = new WebCamCapture();
webcam.FrameNumber = ((ulong)(0ul));
webcam.TimeToCapture_milliseconds = FrameNumber;
webcam.ImageCaptured += new WebCamCapture.WebCamEventHandler(webcam_ImageCaptured);
_FrameImage = ImageControl;
}
void webcam_ImageCaptured(object source, WebcamEventArgs e)
{
_FrameImage.Source = LoadBitmap((System.Drawing.Bitmap)e.WebCamImage);
}
public static BitmapSource LoadBitmap(System.Drawing.Bitmap source)
{
ip = source.GetHbitmap();
bs = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(ip, IntPtr.Zero, System.Windows.Int32Rect.Empty,
System.Windows.Media.Imaging.BitmapSizeOptions.FromEmptyOptions());
DeleteObject(ip);
return bs;
}
i just call one start method from .cs file
public void patientvideostart(object parameter)
{
webcam.Start();
}
in code behind "ref imagevideo" is a image control .i changed to a property"ref Imagevideo".so in here i got the error.
"A property,indexer or dynamic member access may not be passed as an out or ref parameter"
what i can do for getting the video streaming in mvvm.advance thanks..
<pre lang="c#">