locked
Cannot find Front, Back Camera in windows 8.1 store app

    Question

  • I have developed windows 8.1 store app, it need to be capture photo by using back camera and post.

    MediaCaptureInitializationSettings _captureSettings = new var devices = await DeviceInformation.FindAllAsync(DeviceClass.VideoCapture);
        foreach (var device in devices)
        {
        if (device.EnclosureLocation != null && device.EnclosureLocation.Panel == Windows.Devices.Enumeration.Panel.Back)
                            {
                                deviceId = device.Id;
                                break;
                            }
                        }
      if (!string.IsNullOrEmpty(deviceId))
                        {
                            _captureSettings.AudioDeviceId = "";
                            _captureSettings.VideoDeviceId = deviceId;
                            _captureSettings.PhotoCaptureSource = Windows.Media.Capture.PhotoCaptureSource.Photo;
                            _captureSettings.StreamingCaptureMode = Windows.Media.Capture.StreamingCaptureMode.Video;
                        }
    captureManager = new MediaCapture();
    await captureManager.InitializeAsync(_captureSettings);
                        await captureManager.ClearEffectsAsync(MediaStreamType.Photo);
                        capturePreview1.Source = captureManager;
                        await captureManager.StartPreviewAsync();

    Here i am getting two devices but that devices EnclosureLocation is null, so i can't find which one is front and back camera.

    so have decided to get second device from list

    deviceId = devices[1].Id;

    but it throws an error like "The current capture source does not have an independent photo stream."
    in the line of initializing MediaCapture

    await captureManager.InitializeAsync(_captureSettings);

    i have tried in windows surface pro 2 and acer devices. Please advise. Thanks in advance.






    Saturday, October 11, 2014 7:24 AM

Answers

  • Hi Saran,

    I tested your code, I can successfully get the back camera with its deviceId, but I can also see the error message as you mentioned: The current capture source does not have an independent photo stream.

    After I comment following line, everything goes well.

                if (!string.IsNullOrEmpty(deviceId))
                {
                    _captureSettings.AudioDeviceId = "";
                    _captureSettings.VideoDeviceId = deviceId;
                    //_captureSettings.PhotoCaptureSource = Windows.Media.Capture.PhotoCaptureSource.Photo;
                    _captureSettings.StreamingCaptureMode = Windows.Media.Capture.StreamingCaptureMode.Video;
                }

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.


    Monday, October 13, 2014 6:15 AM
    Moderator