I'm currently working on a project to record audio on the HoloLens via a standard UWP application. I have used MediaCapture.PrepareLowLagRecordToStorageFileAsync()
to do so. It works fine on PC, however, when I deploy it onto HoloLens, the application breaks with an Exception
with the message "Class not registered".
Does anyone know how to fix this issue?
Edit: Adding the code that within the context of the error:
// 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();
Details on the exception thrown:
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:\Users\xecli\Documents\Git\uwp-media-streaming-sample\UwpMediaStream\Pages\MainPage.xaml.cs:line 601
Edit: On further testing using MediaCapture.StartRecordToStorageFileAsync()
, I seemed to have gotten the same error with the following callstack:
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:\Users\xecli\Documents\Git\uwp-media-streaming-sample\UwpMediaStream\Pages\MainPage.xaml.cs:line 596
You can try to record audio in WMA format on HoloLens. I made some changes in the Basic camera app sample to call the MediaEncodingProfile.CreateWma(AudioEncodingQuality)
method to record audio. And everything works as expected.
Here is the code I changed from line 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;
If it still cannot work after trying this solution, please feel free to feedback.
User contributions licensed under CC BY-SA 3.0