You cannot use navigator.mediaDevices.getUserMedia to call the camera in QQ Browser

< H2 > problem description < / H2 >

use js to call the mobile camera, study the api of navigator.mediaDevices.getUserMedia, but successfully call up the camera on other mobile browsers, but QQ Browser cannot call it, and QQ Browser"s kernel version also supports the api, without any error message!

add another question:

after using constraints parameter modification,
facingMode: "environment"
is still proactive in actual use.
how sad!

< hr > < H2 > the environmental background of the problem and what methods you have tried < / H2 >

I have tried to use compatible processing methods:

clipboard.png
but still not feasible.

related codes

//

function getUserMedia(constrains,success,error){
    if(navigator.mediaDevices.getUserMedia){
        //API
        navigator.mediaDevices.getUserMedia(constrains).then(success).catch(error);
    } else if (navigator.webkitGetUserMedia){
        //webkit
        navigator.webkitGetUserMedia(constrains).then(success).catch(error);
    } else if (navigator.mozGetUserMedia){
        //Firefox
        navagator.mozGetUserMedia(constrains).then(success).catch(error);
    } else if (navigator.getUserMedia){
        //API
        navigator.getUserMedia(constrains).then(success).catch(error);
    }
}

var video = document.getElementById("video");
var canvas = document.getElementById("canvas");
var context = canvas.getContext("2d");

//
function success(stream){
    //webkit
    var CompatibleURL = window.URL || window.webkitURL;
    //video
    video.src = CompatibleURL.createObjectURL(stream);
    //
    video.play();
}

//
function error(error){
    console.log(":",error.name,error.message);
}
if (navigator.mediaDevices.getUserMedia || navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia){
    //
    const constraints = {
        audio: true, 
        video: {
            width: { ideal: 1280 },
            height: { ideal: 720 },
            frameRate: { 
                ideal: 10,
                max: 15
            },
            facingMode: "environment"
        }
    };
    getUserMedia(constraints,success,error);
} else {
    alert("");
}

//
document.getElementById("capture").addEventListener("click",function(){
    //
    console.log("");
    context.drawImage(video,0,0,480,320);
});
Jul.22,2021

I don't see any problem for the time being, but are you sure the old version of API is not the signature below?

  

can I see the code for the solution

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e50d96-43da0.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e50d96-43da0.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?