locked
select front facing camera RRS feed

  • Question

  • Using the MediaCapture API is it possible to automatically detect the front-facing camera?

    Thursday, November 21, 2013 3:06 PM

Answers

  • Hi , Andrei ,

    In the Windows 8 Capture sample Microsoft has the below lines of code

    When you press the button to start the device.

                   

     EnableButton(false, "Start Device");
                  //  ShowStatusMessage("Starting device");
                    m_mediaCaptureMgr = new Windows.Media.Capture.MediaCapture();
                    var settings = new Windows.Media.Capture.MediaCaptureInitializationSettings();
                    var chosenDevInfo = m_devInfoCollection[EnumedDeviceList2.SelectedIndex];
                    settings.VideoDeviceId = chosenDevInfo.Id;

                    if (chosenDevInfo.EnclosureLocation != null && chosenDevInfo.EnclosureLocation.Panel == Windows.Devices.Enumeration.Panel.Back)
                    {
                        m_bRotateVideoOnOrientationChange = true;
                        m_bReversePreviewRotation = false;
                    }
                    else if (chosenDevInfo.EnclosureLocation != null && chosenDevInfo.EnclosureLocation.Panel == Windows.Devices.Enumeration.Panel.Front)
                    {
                        m_bRotateVideoOnOrientationChange = true;
                        m_bReversePreviewRotation = true;
                    }
                    else
                    {
                        m_bRotateVideoOnOrientationChange = false;
                    }

                    await m_mediaCaptureMgr.InitializeAsync(settings);

                    DisplayProperties_OrientationChanged(null);

                    EnableButton(true, "Start Preview");
                    EnableButton(true, "StartStopRecord");
                    EnableButton(true, "Take Photo");
                    ShowStatusMessage("Device initialized successful");

                    m_mediaCaptureMgr.RecordLimitationExceeded += new Windows.Media.Capture.RecordLimitationExceededEventHandler(RecordLimitationExceeded); ;
                    m_mediaCaptureMgr.Failed += new Windows.Media.Capture.MediaCaptureFailedEventHandler(Failed); ;

    Does this help ??

    Windows.Devices.Enumeration.Panel.Front 

    Also If I remember correctly if you loop through your enum devices the first one is always the front camera.

    thank you


    • Edited by zakkar Friday, November 22, 2013 7:28 AM
    • Marked as answer by Anne Jing Wednesday, November 27, 2013 9:22 AM
    Friday, November 22, 2013 7:26 AM