丢失相机连接时如何保存视频录制?

时间:2013-12-18 19:51:53

标签: c# video windows-8 microsoft-metro webcam

我在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?!
            }
    });
}

谢谢,
莫纳

0 个答案:

没有答案
相关问题