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


C# MediaCapture.StartRecordToStorageFileAsync方法代码示例

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


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

示例1: btnRecord_Click

        //Record the Screen
        private async void btnRecord_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
        {
            if (btnRecord.IsChecked.HasValue && btnRecord.IsChecked.Value)
            {
                // Initialization - Set the current screen as input
                var scrCaptre = ScreenCapture.GetForCurrentView();              

                mCap = new MediaCapture();
                await mCap.InitializeAsync(new MediaCaptureInitializationSettings
                {
                    VideoSource = scrCaptre.VideoSource,
                    AudioSource = scrCaptre.AudioSource,
                });

                // Start Recording to a File and set the Video Encoding Quality
                var file = await GetScreenRecVdo();
                await mCap.StartRecordToStorageFileAsync(MediaEncodingProfile.CreateMp4(VideoEncodingQuality.Auto), file);
            }
            else
            {
                // Stop recording and start playback of the file
                await StopRecording();

                //If Media Element is taken on XAML
                //var file = await GetScreenRecVdo(CreationCollisionOption.OpenIfExists);
                //OutPutScreen.SetSource(await file.OpenReadAsync(), file.ContentType);
            }
        }       
开发者ID:dinhchitrung,项目名称:screencapture-winphone,代码行数:29,代码来源:MainPage.xaml.cs

示例2: 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

示例3: RecordSound

        public async void RecordSound()
        {
            _recordMediaCapture = new MediaCapture();
            var settings = new MediaCaptureInitializationSettings
            {
                StreamingCaptureMode = StreamingCaptureMode.Audio,
                MediaCategory = MediaCategory.Other,
                AudioProcessing = AudioProcessing.Default
            };
            await _recordMediaCapture.InitializeAsync(settings);

            _url = string.Format("Sound_{0}.{1}", Guid.NewGuid(), "aac");
            var path = Path.Combine(StorageService.SoundPath);
            var folder = await StorageFolder.GetFolderFromPathAsync(path);

            _recordStorageFile = await folder.CreateFileAsync(_url);
            MediaEncodingProfile profil = MediaEncodingProfile.CreateM4a(AudioEncodingQuality.Auto);
            await _recordMediaCapture.StartRecordToStorageFileAsync(profil, _recordStorageFile);
        }
开发者ID:india-rose,项目名称:xamarin-indiarose,代码行数:19,代码来源:MediaService.cs

示例4: StartRecording

        private async void StartRecording()
        {

            try
            {
                // Get instance of the ScreenCapture object
                var screenCapture = Windows.Media.Capture.ScreenCapture.GetForCurrentView();

                // Set the MediaCaptureInitializationSettings to use the ScreenCapture as the
                // audio and video source.
                var mcis = new Windows.Media.Capture.MediaCaptureInitializationSettings();
                mcis.VideoSource = screenCapture.VideoSource;
                mcis.AudioSource = screenCapture.AudioSource;
                mcis.StreamingCaptureMode = Windows.Media.Capture.StreamingCaptureMode.AudioAndVideo;

                // Initialize the MediaCapture with the initialization settings.
                _mediaCapture = new MediaCapture();
                await _mediaCapture.InitializeAsync(mcis);

                // Set the MediaCapture to a variable in App.xaml.cs to handle suspension.
                (App.Current as App).MediaCapture = _mediaCapture;

                // Hook up events for the Failed, RecordingLimitationExceeded, and SourceSuspensionChanged events
                _mediaCapture.Failed += new Windows.Media.Capture.MediaCaptureFailedEventHandler(RecordingFailed);
                _mediaCapture.RecordLimitationExceeded += 
                    new Windows.Media.Capture.RecordLimitationExceededEventHandler(RecordingReachedLimit);
                screenCapture.SourceSuspensionChanged += 
                    new Windows.Foundation.TypedEventHandler<ScreenCapture, SourceSuspensionChangedEventArgs>(SourceSuspensionChanged);

                // Create a file to record to.                 
                var videoFile = await ApplicationData.Current.LocalFolder.CreateFileAsync("recording.mp4", CreationCollisionOption.ReplaceExisting);

                // Create an encoding profile to use.                  
                var profile = Windows.Media.MediaProperties.MediaEncodingProfile.CreateMp4(Windows.Media.MediaProperties.VideoEncodingQuality.HD1080p);

                // Start recording
                var start_action = _mediaCapture.StartRecordToStorageFileAsync(profile, videoFile);
                start_action.Completed += CompletedStart;

                // Set a tracking variable for recording state in App.xaml.cs
                (App.Current as App).IsRecording = true;

            }
            catch (Exception ex)
            {
                NotifyUser("StartRecord Exception: " + ex.Message, NotifyType.ErrorMessage);
            }
        }
开发者ID:SoftwareFactoryUPC,项目名称:ProjectTemplates,代码行数:48,代码来源:MainPage.xaml.cs

示例5: 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

示例6: record_Tapped

        //录音初始化
        private async void record_Tapped(object sender, TappedRoutedEventArgs e)
        {

            try
            {
                _mediaCaptureManager = new MediaCapture();
                var settings = new MediaCaptureInitializationSettings();
                settings.StreamingCaptureMode = StreamingCaptureMode.Audio;//设置为音频

                await _mediaCaptureManager.InitializeAsync(settings);


                gridRecord.Visibility = Visibility.Visible;
                myChat.Visibility = Visibility.Collapsed;

                record.IsTapEnabled = false;
                storyboard.Begin();


                String fileName = "1.aac";
                _recordStorageFile = await KnownFolders.MusicLibrary.CreateFileAsync(fileName, CreationCollisionOption.ReplaceExisting);
                MediaEncodingProfile recordProfile = MediaEncodingProfile.CreateM4a(AudioEncodingQuality.Auto);//录音
                await _mediaCaptureManager.StartRecordToStorageFileAsync(recordProfile, this._recordStorageFile);//将录音保存到视频库





            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message.ToString());
            }
        }
开发者ID:x01673,项目名称:dreaming,代码行数:35,代码来源:Chat.xaml.cs

示例7: Initialize

        private async void Initialize()
        {
            try
            {

                var mediaCapture = new MediaCapture();
                await mediaCapture.InitializeAsync();

                var file = await ApplicationData.Current.LocalFolder.CreateFileAsync(Guid.NewGuid() + ".mp4",
                CreationCollisionOption.ReplaceExisting);

                await mediaCapture.StartRecordToStorageFileAsync(MediaEncodingProfile.CreateMp4(VideoEncodingQuality.Wvga), file);

                var videoDev = mediaCapture.VideoDeviceController;
                videoDev.TorchControl.Enabled = true;

                _torchControl = videoDev.TorchControl;
                TorchSupported = _torchControl.Supported;
                TorchPowerSupported = _torchControl.PowerSupported;

                if (TorchPowerSupported)
                    _torchControl.PowerPercent = PercentValue;

                if (TorchSupported)
                    _torchControl.Enabled = IsOn;

                _isInitialized = true;
                _toggleTorchCommand.RaiseCanExecuteChanged();
            }
            catch (Exception ex)
            {
                ErrorMessage = "Etwas unerwartetes ist passiert. Entschuldige!";
            }
        }
开发者ID:famoser,项目名称:Torch,代码行数:34,代码来源:MainViewModel.cs


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