protected override async void OnNavigatedFrom(NavigationEventArgs e) { if (_mediaRecording != null) { await _mediaRecording.StopAsync(); await _mediaRecording.FinishAsync(); } _mediaCapture.Dispose(); }
internal async Task CancelRecordingAsync() { await _mediaRecording.StopAsync(); await _mediaRecording.FinishAsync(); _mediaRecording = null; await savedVideoFile.DeleteAsync(StorageDeleteOption.PermanentDelete); savedVideoFile = null; }
public async Task StopAsync() { try { if (m_lowLag != null) { await m_lowLag.StopAsync(); await m_lowLag.FinishAsync(); } else { await m_mediaCapture.StopRecordAsync(); } m_mediaCapture.Dispose(); m_mediaCapture = null; if (m_opusSink is IDisposable disposable) { disposable.Dispose(); m_opusSink = null; } } catch { } }
private async void TakeVideoAsync() { mediaCapture = new MediaCapture(); await mediaCapture.InitializeAsync(); if (isVideoStarted == false) { var myVideos = await Windows.Storage.StorageLibrary.GetLibraryAsync(Windows.Storage.KnownLibraryId.Videos); StorageFile file = await myVideos.SaveFolder.CreateFileAsync("video.mp4", CreationCollisionOption.GenerateUniqueName); _mediaRecording = await mediaCapture.PrepareLowLagRecordToStorageFileAsync( MediaEncodingProfile.CreateMp4(VideoEncodingQuality.Auto), file); await _mediaRecording.StartAsync(); isVideoStarted = true; } else { await _mediaRecording.StopAsync(); await _mediaRecording.FinishAsync(); } }
public async Task StopRecordingAsync() { await _mediaRecording.StopAsync(); await _mediaRecording.FinishAsync(); _randomAccessStream.Dispose(); }
public async Task StopVideoCapture() { //<SnippetStopRecording> await _mediaRecording.StopAsync(); //</SnippetStopRecording> //<SnippetFinishAsync> await _mediaRecording.FinishAsync(); //</SnippetFinishAsync> }
private async Task EndRecording() { try { await mediaRecording.StopAsync(); await mediaRecording.FinishAsync(); mediaRecording = null; Debug.WriteLine("EndR - " + currentFileName); } catch (Exception ex) { AppendPlayLog("End Recording Exception:", ex.Message); } }
private async void btnPublish_Unchecked(object sender, RoutedEventArgs e) { try { if (_displayRequest != null) { _displayRequest.RequestRelease(); _displayRequest = null; } if (_clockTimer != null) { _clockTimer.Change(Timeout.Infinite, Timeout.Infinite); _clockTimer = null; tbClock.Text = ""; } if (_deviceManager.IsPublishing) { if (_deviceManager.EnableLowLatency && _lowlagCapture != null) { await _lowlagCapture.FinishAsync(); } else { await _deviceManager.CurrentCapture.StopRecordAsync(); } } _deviceManager.IsPreviewing = false; await _deviceManager.CurrentCapture.StartPreviewAsync(); await _deviceManager.SaveHistoryAsync(); } catch (Exception Ex) { } _deviceManager.IsPublishing = false; }
private async void StopBtn_OnClick(object sender, RoutedEventArgs e) { await lowLagMedia.FinishAsync(); }
private async void Finish() { await _mediaRecording.StopAsync(); await _mediaRecording.FinishAsync(); }
private async void stopVideoStreamBtn_Click(object sender, RoutedEventArgs e) { await mediaRecording.StopAsync(); await mediaRecording.FinishAsync(); }
private async void ToggleButton_Checked(object sender, RoutedEventArgs e) { var button = (ToggleButton)sender; // get storage folder if (storageFolder == null) { var msg = new MessageDialog("Please choose a folder first..."); await msg.ShowAsync(); button.IsChecked = false; return; } // check storage folder permissions try { var files = await storageFolder.GetFilesAsync(); } catch { var dialog = new MessageDialog( "The selected storage directory does not exist anymore or is not accessable. Please select a new directory.", "Directory not found or not enough permissions"); await dialog.ShowAsync(); button.IsChecked = false; return; } var requestSuspensionExtension = new ExtendedExecutionForegroundSession(); requestSuspensionExtension.Reason = ExtendedExecutionForegroundReason.Unspecified; var requestExtensionResult = await requestSuspensionExtension.RequestExtensionAsync(); // get storage files var time = DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss_"); var screenFile = await storageFolder.CreateFileAsync(time + "slides.mp4"); var webcamFile = await storageFolder.CreateFileAsync(time + "talkinghead.mp4"); var jsonFile = await storageFolder.CreateFileAsync(time + "meta.json"); // get encoder properties var frameRate = uint.Parse(((string)FrameRateComboBox.SelectedItem).Replace("fps", "")); var quality = (VideoEncodingQuality)Enum.Parse(typeof(VideoEncodingQuality), (string)QualityComboBox.SelectedItem, false); var useSourceSize = UseCaptureItemSizeCheckBox.IsChecked.Value; var temp = MediaEncodingProfile.CreateMp4(quality); uint bitrate = 2500000; var width = temp.Video.Width; var height = temp.Video.Height; // get capture item var picker = new GraphicsCapturePicker(); captureItem = await picker.PickSingleItemAsync(); if (captureItem == null) { button.IsChecked = false; return; } // use the capture item's size for the encoding if desired if (useSourceSize) { width = (uint)captureItem.Size.Width; height = (uint)captureItem.Size.Height; } // we have a screen resolution of more than 4K? if (width > 1920) { var v = width / 1920; width = 1920; height /= v; } // even if we're using the capture item's real size, // we still want to make sure the numbers are even. width = EnsureEven(width); height = EnsureEven(height); // tell the user we've started recording var originalBrush = MainTextBlock.Foreground; MainTextBlock.Foreground = new SolidColorBrush(Colors.Red); MainProgressBar.IsIndeterminate = true; button.IsEnabled = false; MainTextBlock.Text = "3"; await Task.Delay(1000); MainTextBlock.Text = "2"; await Task.Delay(1000); MainTextBlock.Text = "1"; await Task.Delay(1000); button.IsEnabled = true; MainTextBlock.Text = "● rec"; _timerCount = 0; _timer.Start(); try { // start webcam recording MediaEncodingProfile webcamEncodingProfile = null; if (AdaptBitrateCheckBox.IsChecked.Value) { var selectedItem = WebcamComboBox.SelectedItem as ComboBoxItem; var encodingProperties = (selectedItem.Tag as StreamPropertiesHelper); if (encodingProperties.Height > 720) { webcamEncodingProfile = MediaEncodingProfile.CreateMp4(VideoEncodingQuality.HD1080p); webcamEncodingProfile.Video.Bitrate = 8000000; } else if (encodingProperties.Height > 480) { webcamEncodingProfile = MediaEncodingProfile.CreateMp4(VideoEncodingQuality.HD720p); webcamEncodingProfile.Video.Bitrate = 5000000; } else { webcamEncodingProfile = MediaEncodingProfile.CreateMp4(VideoEncodingQuality.Auto); } } else { webcamEncodingProfile = MediaEncodingProfile.CreateMp4(VideoEncodingQuality.Auto); } mediaRecording = await mediaCapture.PrepareLowLagRecordToStorageFileAsync(webcamEncodingProfile, webcamFile); // kick off the screen encoding parallel using (var stream = await screenFile.OpenAsync(FileAccessMode.ReadWrite)) using (screenCapture = new Encoder(screenDevice, captureItem)) { // webcam recording if (mediaCapture != null) { await mediaRecording.StartAsync(); } // screen recording await screenCapture.EncodeAsync( stream, width, height, bitrate, frameRate); } MainTextBlock.Foreground = originalBrush; // user has finished recording, so stop webcam recording await mediaRecording.StopAsync(); await mediaRecording.FinishAsync(); _timer.Stop(); } catch (Exception ex) { _timer.Stop(); var dialog = new MessageDialog( $"Uh-oh! Something went wrong!\n0x{ex.HResult:X8} - {ex.Message}", "Recording failed"); await dialog.ShowAsync(); button.IsChecked = false; MainTextBlock.Text = "failure"; MainTextBlock.Foreground = originalBrush; MainProgressBar.IsIndeterminate = false; captureItem = null; if (mediaRecording != null) { await mediaRecording.StopAsync(); await mediaRecording.FinishAsync(); } return; } // at this point the encoding has finished MainTextBlock.Text = "saving..."; // save slide markers var recording = new Recording() { Slides = screenCapture.GetTimestamps() }; var settings = new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() }; var json = JsonConvert.SerializeObject(recording, Formatting.Indented, settings); await FileIO.WriteTextAsync(jsonFile, json); // add metadata var recordingMetadataDialog = new RecordingMetadataDialog(); var recordingMetadataDialogResult = await recordingMetadataDialog.ShowAsync(); if (recordingMetadataDialogResult == ContentDialogResult.Primary) { recording.Description = recordingMetadataDialog.LectureTitle; if (recordingMetadataDialog.LectureDate.HasValue) { recording.LectureDate = recordingMetadataDialog.LectureDate.Value.DateTime; } } else { recording.Description = null; recording.LectureDate = DateTime.Now; } json = JsonConvert.SerializeObject(recording, Formatting.Indented, settings); await FileIO.WriteTextAsync(jsonFile, json); // tell the user we're done button.IsChecked = false; MainTextBlock.Text = "done"; MainProgressBar.IsIndeterminate = false; requestSuspensionExtension.Dispose(); }
private async Task RecStop() { await _mediaRecording.StopAsync(); await _mediaRecording.FinishAsync(); }
async Task Stop() { await recorder.StopAsync(); await recorder.FinishAsync(); }