/// <summary> /// Record button tapped for either starting or stopping video recording /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void RecordButton_Tapped(object sender, TappedRoutedEventArgs e) { if (_isRecording) { RecordSymbol.Symbol = Symbol.Target; await StopVideoRecordingAsync(); await _mediaCapture.ClearEffectsAsync(MediaStreamType.VideoRecord); if (_sphericalProjectionEffect != null) { if (_sphericalProjectionEffect.SphericalProjection.IsEnabled) { _mediaPlayerProjection.IsEnabled = (_mediaPlayerProjection.FrameFormat == SphericalVideoFrameFormat.Equirectangular) || (ToggleForceSpherical.IsChecked == true); _mediaPlayerProjection.FrameFormat = _sphericalProjectionEffect.SphericalProjection.FrameFormat; _mediaPlayerProjection.HorizontalFieldOfViewInDegrees = _sphericalProjectionEffect.SphericalProjection.HorizontalFieldOfViewInDegrees; _mediaPlayerProjection.ProjectionMode = _sphericalProjectionEffect.SphericalProjection.ProjectionMode; _mediaPlayerProjection.ViewOrientation = _sphericalProjectionEffect.SphericalProjection.ViewOrientation; } _sphericalProjectionEffect = null; } } else { RecordSymbol.Symbol = Symbol.Stop; if (ToggleRecordProjection.IsChecked == true) { _sphericalProjectionEffect = new Windows.Media.Effects.VideoTransformEffectDefinition(); _sphericalProjectionEffect.SphericalProjection.IsEnabled = _mediaPlayerProjection.IsEnabled; _sphericalProjectionEffect.SphericalProjection.FrameFormat = _mediaPlayerProjection.FrameFormat; _sphericalProjectionEffect.SphericalProjection.HorizontalFieldOfViewInDegrees = _mediaPlayerProjection.HorizontalFieldOfViewInDegrees; _sphericalProjectionEffect.SphericalProjection.ProjectionMode = _mediaPlayerProjection.ProjectionMode; _sphericalProjectionEffect.SphericalProjection.ViewOrientation = _mediaPlayerProjection.ViewOrientation; _mediaPlayerProjection.IsEnabled = false; await _mediaCapture.AddVideoEffectAsync(_sphericalProjectionEffect, MediaStreamType.VideoRecord); } await StartVideoRecordingAsync(); } _isRecording = !_isRecording; await EnableDisableCameraControlsOnUI(!_isRecording); }
/// <summary> /// On application suspending /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void Application_Suspending(object sender, SuspendingEventArgs e) { Debug.WriteLine("Application_Suspending"); var deferral = e.SuspendingOperation.GetDeferral(); if (_isRecording) { RecordSymbol.Symbol = Symbol.Target; await StopVideoRecordingAsync(); if (_sphericalProjectionEffect != null) { _sphericalProjectionEffect = null; } } await CleanupCameraAsync(); ResetDisplayRotationPreference(); deferral.Complete(); }