private async void ScenarioClose() { try { if (m_bPhotoSequence) { ShowStatusMessage("Stopping PhotoSequence"); await m_photoSequenceCapture.FinishAsync(); m_photoSequenceCapture = null; m_bPhotoSequence = false; m_framePtr = null; } if (m_bPreviewing) { await m_capture.StopPreviewAsync(); m_bPreviewing = false; } if (m_capture != null) { previewElement4.Source = null; m_capture.Dispose(); } } catch (Exception exception) { ShowExceptionMessage(exception); } }
private async Task openCameraPopup() { MediaCapture mediaCapture = new Windows.Media.Capture.MediaCapture(); await mediaCapture.InitializeAsync(); mediaCapture.Dispose(); }
private async void ScenarioClose() { try { if (m_bRecording) { ShowStatusMessage("Stopping Record"); await m_mediaCaptureMgr.StopRecordAsync(); m_bRecording = false; } if (m_bPreviewing) { ShowStatusMessage("Stopping preview"); await m_mediaCaptureMgr.StopPreviewAsync(); m_bPreviewing = false; } if (m_mediaCaptureMgr != null) { ShowStatusMessage("Stopping Camera"); previewElement1.Source = null; m_mediaCaptureMgr.Dispose(); } } catch (Exception e) { ShowExceptionMessage(e); } }
private async void ScenarioClose() { if (m_bRecording) { ShowStatusMessage("Stopping Record on invisibility"); await m_mediaCaptureMgr.StopRecordAsync(); m_bRecording = false; EnableButton(true, "StartStopRecord"); m_mediaCaptureMgr.Dispose(); } if (m_mediaCaptureMgr != null) { m_mediaCaptureMgr.Dispose(); } }
async public void initPhotoControl() { setMediaCaptureInitializationSettings(); // reset all properties if photoManager contains an object. if (_captureManager != null) { _captureManager.Dispose(); _captureManager = null; } _captureManager = new MediaCapture(); await _captureManager.InitializeAsync(getMediaCaptureInitializationSettings()); cptElementShowPreview.Source = _captureManager; await _captureManager.StartPreviewAsync(); DisplayInformation displayInfo = DisplayInformation.GetForCurrentView(); displayInfo.OrientationChanged += DisplayInfo_OrientationChanged; DisplayInfo_OrientationChanged(displayInfo, null); }
public async Task<RecordingToken> StartAsync() { var capture = new MediaCapture(); var initSettings = new MediaCaptureInitializationSettings(); initSettings.StreamingCaptureMode = StreamingCaptureMode.Audio; await capture.InitializeAsync(initSettings); var fileName = DateTimeOffset.Now.TimeOfDay.ToString().Replace(':', '_') + ".wav"; var file = await ApplicationData.Current.LocalFolder.CreateFileAsync(fileName); var profile = MediaEncodingProfile.CreateWav(AudioEncodingQuality.Medium); await capture.StartRecordToStorageFileAsync(profile, file); return new RecordingToken(file.Path, async () => { await capture.StopRecordAsync(); // It's important to dispose the capture device here to avoid application crash when using FileSavePicker afterwards capture.Dispose(); }); }
// </SnippetMediaCaptureVideo_StopRecordCS> // </SnippetMediaCaptureVideo_CompleteCS> public async Task CleanupCaptureResources() { if (_recording && _mediaCapture != null) { await _mediaCapture.StopRecordAsync(); _recording = false; } if (_previewing && _mediaCapture != null) { await _mediaCapture.StopPreviewAsync(); _previewing = false; } if (_mediaCapture != null) { if (previewElement != null) { previewElement.Source = null; } _mediaCapture.Dispose(); } }
private async Task<bool> IsMicrophoneAvailable() { // Error messages from: https://msdn.microsoft.com/en-us/library/windows/apps/hh768223.aspx#additional_usage_guidance try { // We do this initialization (and tear down immediately after) just to check if we have access to a microphone. // We'll do the actual work with NAudio, since MediaCapture doesn't supply raw PCM data that we need. var mediaCapture = new MediaCapture(); await mediaCapture.InitializeAsync(); mediaCapture.Dispose(); return true; } catch (UnauthorizedAccessException) { RaiseMicrophoneIsNotAvailable( "Your microphone is currently turned off. To change your microphone setting, open the settings charm and tap permissions. " + "Then tap the mute button to start using microphone again."); return false; } catch (Exception) { RaiseMicrophoneIsNotAvailable( "You do not have the required microphone present on your system."); return false; } }
// Must be called on the UI thread private async Task DisposeCaptureAsync() { Preview.Source = null; if (autoFocus != null) { autoFocus.Dispose(); autoFocus = null; } MediaCapture mediaCapture; lock (this) { mediaCapture = this.mediaCapture; this.mediaCapture = null; } if (mediaCapture != null) { mediaCapture.Failed -= OnMediaCaptureFailed; await mediaCapture.StopPreviewAsync(); mediaCapture.Dispose(); } }
public async void Capture_Click(object sender, RoutedEventArgs e) { MediaCapture mediaCapture = new MediaCapture(); await mediaCapture.InitializeAsync(); if (mediaCapture.VideoDeviceController.LowLagPhotoSequence.Supported) { mediaCapture.Dispose(); Frame.Navigate(typeof(SequenceCapturePage)); } else { mediaCapture.Dispose(); Frame.Navigate(typeof(VideoPreviewCapturePage)); } }