MediaCapture.PrepareLowLagRecordToStorageFileAsync() 在 HoloLens 上抛出"Class not registered"异常



我目前正在做一个项目,通过标准的UWP应用程序在HoloLens上录制音频。我用MediaCapture.PrepareLowLagRecordToStorageFileAsync()来做到这一点。它在PC上运行良好,但是,当我将其部署到HoloLens上时,应用程序会中断,并显示一条Exception消息"类未注册"。

有谁知道如何解决这个问题?

编辑:添加在错误上下文中的代码:

// Create the Media Encoding Profile we are going to use
var mediaEncodingProfile = MediaEncodingProfile.CreateFlac(AudioEncodingQuality.High);
mediaEncodingProfile.Audio.ChannelCount = 1;
// Create the file to store the recording in
var localFolder = Windows.Storage.ApplicationData.Current.LocalFolder;
var audioRecordingFile = await localFolder.CreateFileAsync("audio.mp3", CreationCollisionOption.GenerateUniqueName);
// Prepare for recording
mediaRecording = await mediaCapture.PrepareLowLagRecordToStorageFileAsync
(
mediaEncodingProfile,
audioRecordingFile 
);
// Begin recording
await mediaRecording.StartAsync();

有关引发的异常的详细信息:

System.Exception
HResult=0x80040154
Message=Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))
Source=System.Private.CoreLib
StackTrace:
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at UwpMediaStream.MainPage.<dictationToggleGcp_Click>d__39.MoveNext() in D:UsersxecliDocumentsGituwp-media-streaming-sampleUwpMediaStreamPagesMainPage.xaml.cs:line 601

编辑:在使用MediaCapture.StartRecordToStorageFileAsync()进一步测试时,我似乎在以下调用堆栈中遇到了相同的错误:

System.Exception
HResult=0x80040154
Message=Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))
Source=System.Private.CoreLib
StackTrace:
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at UwpMediaStream.MainPage.<dictationToggleGcp_Click>d__39.MoveNext() in D:UsersxecliDocumentsGituwp-media-streaming-sampleUwpMediaStreamPagesMainPage.xaml.cs:line 596

你可以尝试在HoloLens上录制WMA格式的音频。我在基本相机应用示例中进行了一些更改,以调用MediaEncodingProfile.CreateWma(AudioEncodingQuality)方法来录制音频。一切都按预期工作。

这是我从第 411 行更改的代码:

var voiceFile = await _captureFolder.CreateFileAsync("SimpleVoice.wma", CreationCollisionOption.GenerateUniqueName);
var encodingProfile = MediaEncodingProfile.CreateWma(AudioEncodingQuality.Auto);
//encodingProfile.Video.Properties.Add(RotationKey, PropertyValue.CreateInt32(rotationAngle));
//encodingProfile.Audio.ChannelCount = 1;

如果在尝试此解决方案后仍然无法正常工作,请随时反馈。

相关内容

最新更新