我在Metro风格的应用程序C#中使用MediaCapture来预览网络摄像头和录制视频。
丢失相机连接时调用失败的方法。我在丢失相机连接时尝试调用StopRecordAsync(),但我有一个例外,因为视频录制设备不再存在。
有没有办法在视频连接丢失时停止录制并保存录制视频文件?
public async void Failed(MediaCapture currentCaptureObject, MediaCaptureFailedEventArgs currentFailure)
{
await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async () =>
{
if (m_bRecording)
try
{
await m_mediaCaptureMgr.StopRecordAsync();
}
catch (Exception ex)
{
// I have this exception : {System.Exception: The video recording
// device is no longer present. is there a way to stop the
// recording and save the video file if the video connection is lost?!
}
});
}
谢谢,
莫纳