Windows 8 how to choose which camera to initialize

扶醉桌前 提交于 2019-12-06 20:37:27

You have to create a MediaCaptureInitializationSettings object:

var settings = new Windows.Media.Capture.MediaCaptureInitializationSettings();
settings.videoDeviceId = devices[1].id;
mediaCaptureMgr.initializeAsync(settings).done(initializeComplete, initializeError);

Just to complete the "ma_il" correct answer, is not always true that devices[1] is the back camera on devices other than Surface. To test where the camera and other devices are placed you have to check if device information contains other important info as reported on this article: http://msdn.microsoft.com/en-us/library/windows/apps/hh464961.aspx

Complete code should look like this

if (devices.length > 0) {
    devices.forEach(function (currDev) {
        if (currDev.enclosureLocation.panel && currDev.enclosureLocation.panel == Windows.Devices.Enumeration.Panel.back) {
             defaultDeviceId = currDev.id;
        }
    })
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!