For a Windows Phone 8.1 app I have to record a video.
I used this instructions and it works basically... http://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh868171.aspx
... but I do not get the cleaning up part within the App.xaml.cs
public MediaCapture MediaCapture { get; set; }
public CaptureElement PreviewElement { get; set; }
public bool IsRecording { get; set; }
public bool IsPreviewing { get; set; }
public async Task CleanupCaptureResources()
{
if (IsRecording && MediaCapture != null)
{
await MediaCapture.StopRecordAsync();
IsRecording = false;
}
if (IsPreviewing && MediaCapture != null)
{
await MediaCapture.StopPreviewAsync();
IsPreviewing = false;
}
if (MediaCapture != null)
{
if (PreviewElement != null)
{
PreviewElement.Source = null;
}
MediaCapture.Dispose();
}
}
private async void OnSuspending(object sender, SuspendingEventArgs e)
{
var deferral = e.SuspendingOperation.GetDeferral();
//cleanup camera resources
await CleanupCaptureResources();
deferral.Complete();
}
I don't get how the connection between App.xaml.cs and VideoRec.xaml (whrere the preview element is) has to work. This is probably a very basic thing... I am very grateful for every hint or a link for a tutorial for beginners how to handle MediaCapture at all. Everything I have found is for advanced.