MediaCapture 间歇性失败(RecordState - 操作无效)

MediaCapture failing intermittently (RecordState - The op is invalid)

我正在使用 MediaCapture API 在我的 Windows Phone 8.1 RT 应用程序中录制音频。录音工作正常,但 API 间歇性地抛出 System.Exception 并显示以下消息:
RecordState System.Exception: The op is invalid. 在声明中 Windows.Media.Capture.MediaCapture.StartRecordToStorageFileAsync(MediaEncodingProfile encodingProfile, IStorageFile file)

我无法找到有关此错误原因的更多信息。谁能指出某个方向?

找到这个异常的原因。我反复调用 MediaCapture.StartRecordToStorageFileAsync(),即使 MediaCapture 对象已经在录制音频。我必须确保在调用 StartRecordToStorageFileAsync() 之前调用 MediaCapture.StopRecordAsync() 以便不违反记录对象的状态。

同样,多次调用 StopRecordAsync() 会引发类似的异常。

我遇到了同样的问题,正如您所说多次调用 StartRecordToStorageFileAsync() 而没有停止之前使用 StopRecordAsync() 的捕获会产生这种情况。每次我使用的定时器被激活时,我必须确保我没有触发 StartRecordToStorageFileAsync(),我使用了这个:

            if (_PrimeraVez)
            {
                CameraRecord(); //My own method
                _PrimeraVez = false;
            }   

很高兴您自己找到了解决方案。