当前位置: 首页>>代码示例>>C#>>正文


C# MediaCapture.Dispose方法代码示例

本文整理汇总了C#中Windows.Media.Capture.MediaCapture.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# MediaCapture.Dispose方法的具体用法?C# MediaCapture.Dispose怎么用?C# MediaCapture.Dispose使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Windows.Media.Capture.MediaCapture的用法示例。


在下文中一共展示了MediaCapture.Dispose方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: StartAsync

        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();
            });
        }
开发者ID:khmylov,项目名称:talk-windows-phone-sharing,代码行数:22,代码来源:Recorder.cs

示例2: DisposeCaptureAsync

        // 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();
            }
        }
开发者ID:KlubJagiellonski,项目名称:pola-windowsphone,代码行数:27,代码来源:Scanner.xaml.cs

示例3: IsMicrophoneAvailable

 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;
     }
 }
开发者ID:ProMcTagonist,项目名称:OneTox,代码行数:26,代码来源:AudioCallViewModel.cs

示例4: Capture_Click

 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));
     }
 }
开发者ID:modulexcite,项目名称:Lumia-imaging-sdk,代码行数:15,代码来源:SequencesPage.xaml.cs


注:本文中的Windows.Media.Capture.MediaCapture.Dispose方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。