Silverlight 如何获得可访问的相机分辨率?

Silverlight 如何获得可访问的相机分辨率?,silverlight,camera,windows-runtime,windows-phone-8.1,resolution,Silverlight,Camera,Windows Runtime,Windows Phone 8.1,Resolution,我想问一下,如何在Windows Phone 8.1应用程序(silverlight和WinRT)中获得所有可访问的摄像头分辨率。我想用: Windows.Phone.Media.Capture.PhotoCaptureDevice.GetAvailableCaptureResolutions( Windows.Phone.Media.Capture.CameraSensorLocation.Back); 但我收到的消息是,命名空间Windows.Phone.Media.Captur

我想问一下,如何在Windows Phone 8.1应用程序(silverlight和WinRT)中获得所有可访问的摄像头分辨率。我想用:

Windows.Phone.Media.Capture.PhotoCaptureDevice.GetAvailableCaptureResolutions(
     Windows.Phone.Media.Capture.CameraSensorLocation.Back);
但我收到的消息是,命名空间Windows.Phone.Media.Capture已过时,从Windows Phone Blue开始的下一版本Windows Phone可能不支持它,我应该改用Windows.Media.Capture。但是,Windows.Media.Capture不允许我获取可访问的相机分辨率,因此我想问,如何解决此问题


谢谢。

可以这样做:

private async void InitCameraBtn_Click(object sender, RoutedEventArgs e)
{
    var cameraID = await GetCameraID(Windows.Devices.Enumeration.Panel.Back);
    captureManager = new MediaCapture();

    await captureManager.InitializeAsync(new MediaCaptureInitializationSettings
        {
            StreamingCaptureMode = StreamingCaptureMode.Video,
            PhotoCaptureSource = PhotoCaptureSource.VideoPreview,
            AudioDeviceId = string.Empty,
            VideoDeviceId = cameraID.Id
        });
    // Get resolutions
    var resolutions = captureManager.VideoDeviceController.GetAvailableMediaStreamProperties(MediaStreamType.Photo).Select(x => x as VideoEncodingProperties).ToList();
    // get width and height:
    uint width = resolutions[0].Width;
    uint height = resolutions[0].Height;
}
首先,让我们定义获取用于拍照的设备ID的方法:

private static async Task<DeviceInformation> GetCameraID(Windows.Devices.Enumeration.Panel desiredCamera)
{
    DeviceInformation deviceID = (await DeviceInformation.FindAllAsync(DeviceClass.VideoCapture))
            .FirstOrDefault(x => x.EnclosureLocation != null && x.EnclosureLocation.Panel == desiredCamera);

    if (deviceID != null) return deviceID;
    else throw new Exception(string.Format("Camera of type {0} doesn't exist.", desiredCamera));
}