0

我如何强制 Capture 管理器使用后置摄像头,因为我无法在 windows phone 8.1 中使用 CameraCaptureUI。

该应用程序启动默认前置摄像头。

这是我的代码:

function initCaptureSettings() {
    captureInitSettings = null;
    captureInitSettings =
        new Windows.Media.Capture.MediaCaptureInitializationSettings();
    captureInitSettings.photoCaptureSource = Windows.Media.Capture.PhotoCaptureSource.photo;
    captureInitSettings.streamingCaptureMode =
        Windows.Media.Capture.StreamingCaptureMode.audioAndVideo;
    startDevice();
}


function startDevice() {
    Debug.writeln("Starting device");
    releaseMediaCapture();
    mediaCaptureMgr = new Windows.Media.Capture.MediaCapture();
    mediaCaptureMgr.initializeAsync(captureInitSettings).done(function (result) {

        // do we have a camera and a microphone present?
        if (mediaCaptureMgr.mediaCaptureSettings.videoDeviceId && mediaCaptureMgr.mediaCaptureSettings.audioDeviceId) {

            // Update the UI
            Debug.writeln("Device started");


        } else {
            Debug.writeln("No capture device was found");

        }
        startPreview();
    }, errorHandler);
}

function startPreview() {
    Debug.writeln("Starting preview");

    try {
        var video = id("photoCapture");
        //Windows.Media.Capture.CameraOptionsUI.show(mediaCaptureMgr);
        video.src = URL.createObjectURL(mediaCaptureMgr, { oneTimeOnly: true });
        video.play();

    } catch (e) {
        Debug.writeln("Preview failed: " + e.message);
        return;
    }

    Debug.writeln("Preview started");
    intervalID = setInterval(function () {
        capturePhoto();
    }, 1500);
}

我想这是设置中的东西。

4

1 回答 1

0

尝试这个

var devices = await DeviceInformation.FindAllAsync(DeviceClass.VideoCapture);

await mediaCaptureMgr.InitializeAsync(new MediaCaptureInitializationSettings
{
      VideoDeviceId = devices[1].Id
});
于 2014-07-19T20:02:10.147 回答