protected override async void OnActivated(EventArgs e) { var capture = new MediaCapture(); await capture.InitializeAsync(); var preview = new CapturePreview(capture); Preview.Source = preview; await preview.StartAsync(); }
protected override async void OnActivated(EventArgs e) { if (m_initialized) { return; // Already initialized } m_initialized = true; var capture = new MediaCapture(); await capture.InitializeAsync(new MediaCaptureInitializationSettings { StreamingCaptureMode = StreamingCaptureMode.Video // No audio }); var preview = new CapturePreview(capture); Preview.Source = preview; await preview.StartAsync(); }
protected override async void OnActivated(EventArgs e) { if (m_initialized) { return; // Already initialized } m_initialized = true; var capture = new MediaCapture(); await capture.InitializeAsync(new MediaCaptureInitializationSettings { StreamingCaptureMode = StreamingCaptureMode.Video // No audio }); var preview = new CapturePreview(capture); Preview.Source = preview; await preview.StartAsync(); }
public async Task StartPreviewAsync() { if (IsPreviewing) { return; } try { mediaCapture = new MediaCapture(); await mediaCapture.InitializeAsync();// there will throw an exception if there no camera device. mediaCapture.Failed += MediaCapture_Failed; displayRequest.RequestActive(); DisplayInformation.AutoRotationPreferences = DisplayOrientations.Landscape; } catch (Exception e)// it will throw exception if there no camera device. { await CleanupCameraAsync(); Debug.WriteLine(e.Message + "++++45"); return; } try { capturePreview = new CapturePreview(mediaCapture); //if (mediaCapture.VideoDeviceController.) //{ // mediaCapture.CaptureDeviceExclusiveControlStatusChanged += MediaCapture_CaptureDeviceExclusiveControlStatusChanged; //} await capturePreview.StartAsync();// it will raise MediaCapture Failed event when camera is used by other application. _isPreviewing = true; } catch (Exception e)// it will throw exception if camera device is used by other application. { Debug.WriteLine(e.Message + "+++62"); } }