1

我有 xamarin 形式的应用程序,我正在访问 webview 进行视频通话。一切正常,只是我需要知道如何在通话期间切换后置/前置摄像头?就像视频通话开始时默认打开前置摄像头一样。

视频通话初始化代码

function initializeLocalMedia(options, callback) {

        if(options) {
            options['audio'] = true;

            if(options['video'])
                options['video'] = true;
        } else {
            options['audio'] = true;
            options['video'] = false;
        }

        // Get audio/video stream
        navigator.getUserMedia(options, function(stream) {
            // Set your video displays
            window.localStream = stream;
            myapp.setMyVideo(window.localStream)
            if(callback)
                callback();
        }, function(err) {
            console.log("The following error occurred: " + err.name);
            alert('Unable to call ' + err.name)
        });
    }
4

1 回答 1

1

直接进入代码然后它应该看起来像:

Camera.CameraInfo camInfo = new Camera.CameraInfo ();
for (int i = 0; i < Camera.NumberOfCameras; i++) {
    Camera.GetCameraInfo (i, camInfo);
    if (camInfo.Facing == CameraFacing.Front){
        try {
            return Camera.Open(i);
        } catch (Exception e) {
            // log or something
        }
    }
}
return null;

我们正在做的是迭代硬件,然后检查是否匹配前置摄像头,如果匹配则执行操作。后置摄像头也是如此

于 2020-06-22T12:59:54.817 回答