System.NotSupportedException:不支持指定的方法 我有时会在调用startSource的Start方法在Windows Phone 8上录制视频时收到此错误。
以下是我的代码:
if (captureSource.VideoCaptureDevice != null
&& captureSource.State == CaptureState.Started)
{
captureSource.Stop();
//UpdateUI(ButtonState.Recording, "Initializing...");
//Create Dir If Not Exist
if (!IsolatedStorageFile.GetUserStoreForApplication().DirectoryExists(FileLocation))
IsolatedStorageFile.GetUserStoreForApplication().CreateDirectory(FileLocation);
DateTime theDate = DateTime.Now;
isoVideoFileName = theDate.ToString("yyyyMMdd") + "_" + theDate.ToString("HHmmss") + "_" + "Video" + "." + GlobalDTO.VideoFormat;
// Connect the input and output of fileSink.
captureSource = new CaptureSource();
captureSource.CaptureFailed += new EventHandler<ExceptionRoutedEventArgs>(OnCaptureFailed);
captureSource.CaptureImageCompleted += captureSource_CaptureImageCompleted;
fileSink.CaptureSource = captureSource;
fileSink.IsolatedStorageFileName = FileLocation + isoVideoFileName;
}
// Begin recording.
if (captureSource.VideoCaptureDevice != null
&& captureSource.State == CaptureState.Stopped)
{
videoRecorderBrush.SetSource(captureSource);
captureSource.Start();
captureSource.CaptureImageAsync();
}
// Set the button states and the message.
UpdateUI(ButtonState.Recording, "Recording...");
答案 0 :(得分:0)
所有手机可能都不支持该功能? 这也许就是为什么你会得到那个例外。您应该捕获异常并以适当的方式处理它以通知用户不支持该功能。