コード例 #1
0
        private async Task StopRecord()
        {
            if (!_isRecording)
            {
                return;
            }

            try
            {
                ShowStatusMessage("Stopping Video Preview");
                //await m_mediaCaptureMgr.StopPreviewAsync();
                ShowStatusMessage("Stopping Video Record");
                await m_mediaCaptureMgr.StopRecordAsync();

                if (m_mediaCaptureMgr != null)
                {
                    ShowStatusMessage("Cleaning Preview");
                    m_mediaCaptureMgr.Dispose();
                    previewElement1.Source = null;
                    m_mediaCaptureMgr      = null;
                }

                if (_isPostToServer)
                {
                    ShowStatusMessage("Closing network");
                    _mediaStream.Disconnect();
                }
                else
                {
                    ShowStatusMessage($"File is saved:{_localFile.Name}");
                    await _localFile.OpenReadAsync();

                    var stream = await _localFile.OpenAsync(FileAccessMode.Read);

                    reviewElement.Visibility   = Visibility.Visible;
                    previewElement1.Visibility = Visibility.Collapsed;

                    reviewElement.AutoPlay = true;
                    reviewElement.SetSource(stream, _localFile.FileType);
                    reviewElement.Play();
                }
                _isRecording = false;

                btnStartRecord.IsEnabled = true;
                btnSaveLocal.IsEnabled   = true;
                btnStopRecord.IsEnabled  = false;

                ShowStatusMessage("Record stopped.");
            }
            catch (Exception ex)
            {
                ShowExceptionMessage("StopRecord", ex);
            }
        }