繁体   English   中英

在wp8中调用captureSource.Start()时发生System.NotSupportedException

[英]System.NotSupportedException while calling captureSource.Start() in wp8

System.NotSupportedException:不支持指定的方法,有时在调用captureSource的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...");

并非所有手机都支持该功能吗? 这也许就是为什么您遇到该异常的原因。 您应该捕获该异常并以适当的方式对其进行处理,以通知用户不支持该功能。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM