7,655
社区成员
发帖
与我相关
我的任务
分享
private AudioVideoCaptureDevice AVCaptureDevice;
private IRandomAccessStream Iras;
private string path;
public MainPage()
{
InitializeComponent();
init();
}
private async void init()
{
AVCaptureDevice= await AudioVideoCaptureDevice.OpenForAudioOnlyAsync();
AVCaptureDevice.AudioEncodingFormat = CameraCaptureAudioFormat.Amr;
}
private async void Record(string fileName="sandcu")
{
StorageFile storageFile=null;
StorageFolder localFolder = ApplicationData.Current.LocalFolder;
IsolatedStorageFile isStore = IsolatedStorageFile.GetUserStoreForApplication();
if (isStore.FileExists(localFolder.Path + "\\"+fileName+".aac"))
{
storageFile = await localFolder.GetFileAsync(fileName+".aac");
}
storageFile = storageFile ?? await localFolder.CreateFileAsync(fileName+".aac", CreationCollisionOption.ReplaceExisting);
path = storageFile.Path;
if (storageFile != null)
{
Iras= await storageFile.OpenAsync(FileAccessMode.ReadWrite);
await AVCaptureDevice.StartRecordingToStreamAsync(Iras);
}
}
private async void StopRecord()
{
await AVCaptureDevice.StopRecordingAsync();
Iras.AsStream().Dispose();
}