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


C# MediaCapture.StopRecordAsync方法代码示例

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


在下文中一共展示了MediaCapture.StopRecordAsync方法的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: PrintMicrophoneSample

        public void PrintMicrophoneSample()
        {
            MediaCapture capture;
            IRandomAccessStream stream;
            const int BufferSize = 64000;
            bool recording;
            float volume = 100;



            capture = new MediaCapture();

            stream = new InMemoryRandomAccessStream();
            var captureInitSettings2 = new MediaCaptureInitializationSettings();
            captureInitSettings2.StreamingCaptureMode = StreamingCaptureMode.Audio;
            capture.InitializeAsync(captureInitSettings2).AsTask().Wait();

            capture.AudioDeviceController.VolumePercent = volume;

            MediaEncodingProfile profile = new MediaEncodingProfile();

            AudioEncodingProperties audioProperties = AudioEncodingProperties.CreatePcm(16000, 1, 16);
            profile.Audio = audioProperties;
            profile.Video = null;
            profile.Container = new ContainerEncodingProperties() { Subtype = MediaEncodingSubtypes.Wave };

            capture.StartRecordToStreamAsync(profile, stream).GetResults();

            recording = true;

            // waste time
            for (int i = 0; i < 5; i++)
            {
                i = i * 232323 + 89;// WriteLine(i);
            }

            capture.StopRecordAsync().GetResults();

            byte[] wav = new byte[stream.Size];
            stream.Seek(0);
            stream.ReadAsync(wav.AsBuffer(), (uint)stream.Size, InputStreamOptions.None).GetResults();

            int sum = 0;
            for(int i = 0; i < wav.Count(); i++)
            {
                sum += (int) wav[i];
            }
            WriteLine((double) wav.Count() / sum);
        }
开发者ID:zidx,项目名称:lights,代码行数:49,代码来源:StartupTask.cs

示例3: MediaCaptureOnRecordLimitationExceeded

 private async void MediaCaptureOnRecordLimitationExceeded(MediaCapture sender)
 {
     await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async () =>
     {
         await sender.StopRecordAsync();
         var warningMessage = new MessageDialog("The media recording has been stopped because you exceeded the maximum recording length.", "Recording Stoppped");
         await warningMessage.ShowAsync();
     });
 }
开发者ID:vulcanlee,项目名称:Windows8Lab,代码行数:9,代码来源:MainPage.xaml.cs

示例4: StartMediaCaptureRecord_Click

        private async void StartMediaCaptureRecord_Click(object sender, RoutedEventArgs e)
        {
            StartCaptureElementRecord.IsEnabled = false;

            // Skip if no camera
            var devices = await DeviceInformation.FindAllAsync(DeviceClass.VideoCapture);
            if (devices.Count == 0)
            {
                return;
            }

            StorageFile destination = await KnownFolders.VideosLibrary.CreateFileAsync("VideoEffectsTestApp.MediaCapture.mp4", CreationCollisionOption.ReplaceExisting);

            var capture = new MediaCapture();
            await capture.InitializeAsync(new MediaCaptureInitializationSettings
            {
                StreamingCaptureMode = StreamingCaptureMode.Video
            });

            var definition = await CreateEffectDefinitionAsync(
                (VideoEncodingProperties)capture.VideoDeviceController.GetMediaStreamProperties(MediaStreamType.VideoRecord)
                );

            await capture.AddEffectAsync(MediaStreamType.VideoRecord, definition.ActivatableClassId, definition.Properties);

            await capture.StartRecordToStorageFileAsync(MediaEncodingProfile.CreateMp4(VideoEncodingQuality.Qvga), destination);

            await Task.Delay(3000);

            await capture.StopRecordAsync();

            StartCaptureElementRecord.IsEnabled = true;
        }
开发者ID:gtarbell,项目名称:VideoEffect,代码行数:33,代码来源:MainPage.xaml.cs


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