mardi 1 décembre 2015

switch from front camera in back camera

I have a big problem I want to enter a QR code in my site, and the funksioniert very good. but at MOBILE (PHONE) activates only the front camera and I want to be in mobile verwändet only the rear camera, the front camera if not jemant can help me I would be grateful sher

function success(stream) {
if(webkit)
    v.src = window.webkitURL.createObjectURL(stream);
else
if(moz)
{
    v.mozSrcObject = stream;
    v.play();
}
else
    v.src = stream;
gUM=true;
setTimeout(captureToCanvas, 500);
}

function error(error) {
gUM=false;
return;
}

function load()
{
if(isCanvasSupported() && window.File && window.FileReader)
{
    initCanvas(800, 600);
    qrcode.callback = read;
    document.getElementById("mainbody").style.display="inline";
    setwebcam();
}
else
{
    document.getElementById("mainbody").style.display="inline";
    document.getElementById("mainbody").innerHTML='<p id="mp1">QR code                      scanner for HTML5 capable browsers</p><br>'+
    '<br><p id="mp2">sorry your browser is not supported</p><br><br>'+
    '<p id="mp1">try <a href="http://ift.tt/mTO3iL"><img src="./firefox.png"/></a> or <a href="http://ift.tt/peH3vs"><img src="./chrome_logo.gif"/></a> or <a href="http://www.opera.com"><img src="./Opera-logo.png"/></a></p>';
}
}

 function setwebcam()
{
document.getElementById("result").innerHTML="- scanning -";
if(stype==1)
{
    setTimeout(captureToCanvas, 500);    
    return;
}
var n=navigator;
document.getElementById("outdiv").innerHTML = vidhtml;
v=document.getElementById("v");

if(n.getUserMedia)
    n.getUserMedia({video: true, audio: false}, success, error);
else
if(n.webkitGetUserMedia)
{
    webkit=true;
    n.webkitGetUserMedia({video:true, audio: false}, success, error);
}
else
if(n.mozGetUserMedia)
{
    moz=true;
    n.mozGetUserMedia({video: true, audio: false}, success, error);
}

//document.getElementById("qrimg").src="qrimg2.png";
//document.getElementById("webcamimg").src="webcam.png";
document.getElementById("qrimg").style.opacity=0.2;
document.getElementById("webcamimg").style.opacity=1.0;

stype=1;
setTimeout(captureToCanvas, 500);
}




Aucun commentaire:

Enregistrer un commentaire