本文整理汇总了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();
});
}
示例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);
}
示例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();
});
}
示例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;
}