protected async override void OnNavigatingFrom(NavigatingCancelEventArgs e)
        {
            base.OnNavigatingFrom(e);

            if (activated)
            {
                RemoteVideo.Stop();
                RemoteVideo.Source = null;
            }

            await device.CleanUpAsync();

            device = null;
        }
        private async Task CleanupAsync()
        {
            try
            {
                if (currentState == State.Previewing || currentState == State.Streaming)
                {
                    await device.CaptureSource.StopPreviewAsync();

                    if (currentState == State.Streaming)
                    {
                        LocalhostVideo.Stop();
                    }
                }


                await device.CleanUpAsync();
            }
            catch (Exception)
            {
            }
            finally
            {
                LocalhostVideo.Source = null;
            }
        }
Exemplo n.º 3
0
        private async Task readCameraProperties()
        {
            var cameraFound = await CaptureDevice.CheckForRecordingDeviceAsync();

            if (cameraFound)
            {
                device = new CaptureDevice();
                await device.InitializeAsync();

                loadAllVideoProperties();
                await device.CleanUpAsync();

                device = null;
            }
            else
            {
                NotifyUser("A machine with a camera and a microphone is required to run this sample.", NotifyType.ErrorMessage);
            }
        }
Exemplo n.º 4
0
        private async Task EndRecording()
        {
            if (device == null)
            {
                return;
            }
            await device.CaptureSource.StopPreviewAsync();

            await device.CleanUpAsync();

            device = null;

            await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, (() =>
            {
                previewElement.Source = null;
            }));

            _isRecording = false;
        }
        private async Task CleanupAsync()
        {
            if (currentState == State.Previewing || currentState == State.Streaming)
            {
                await device.CaptureSource.StopPreviewAsync();

                if (currentState == State.Streaming)
                {
                    LocalhostVideo.Stop();

                    LocalhostVideo.Visibility  = Visibility.Collapsed;
                    LocalHostPoster.Visibility = Visibility.Visible;
                }
            }


            await device.CleanUpAsync();

            LocalhostVideo.Source = null;
        }