Photocapture设备相机在Windows Phone 8中挂起

时间:2013-05-16 07:41:02

标签: c# xaml windows-phone-8 barcode-scanner

我正在Windows Phone 8中开发一个应用程序。基本上在我的应用程序中,我使用PhotoCaptureDevice API来捕捉快照并扫描条形码。当我出门并使用硬件后退按钮连续返回相机页面时,相机页面会挂起而无法继续进行。

The code snippet used is :

//Passing Videobrush to PhotoCapturedevice

VideoBrush brush;

brush.SetSource(_device);

//PhotoCapture Device Intialization

internal PhotoCaptureDevice _device;

CameraSensorLocation cameraLocation;

    if (PhotoCaptureDevice.AvailableSensorLocations.Contains(CameraSensorLocation.Back))
    {
          var supportedResolutions = PhotoCaptureDevice.GetAvailableCaptureResolutions(CameraSensorLocation.Back);
          _initRes = GetBestResolution(supportedResolutions);
           cameraLocation = CameraSensorLocation.Back;

     }
     else if (PhotoCaptureDevice.AvailableSensorLocations.Contains(CameraSensorLocation.Front))
     {
           var supportedResolutions = PhotoCaptureDevice.GetAvailableCaptureResolutions(CameraSensorLocation.Front);
           _initRes = GetBestResolution(supportedResolutions);
            cameraLocation = CameraSensorLocation.Front;

     }  

你能帮我解决这个问题吗?

1 个答案:

答案 0 :(得分:0)

在调用brush.SetSource(_device);

之前,必须初始化photocapture对象