HTML5 call native webcam compatible with Google Chrome version, Google Chrome low version, Firefox browser

Source: Internet
Author: User

Do this function on the Internet to check some information, code as follows, in this code in Google Chrome version 46 is not a problem, in Firefox browser is OK, but in the high version of Google Browser is incompatible

<DivID= "Body">    < Sectionclass= "Featured">        <Divclass= "Content-wrapper">            <Hgroupclass= "title">                <H1>Welcome to Webcam</H1>                <BR/>                <H2>Compatible with Google Chrome 46 version, 48 version, Google Chrome high version, Firefox browser</H2>            </Hgroup>                    </Div>    </ Section>    < Sectionclass= "Content-wrapper main-content clear-fix">        <H3>HTML5 in the local call camera is no problem, but deployed to the external network server, Google Chrome High version needs to change the HTTP to https;<BR/>HTTPS in IIS7.5 configuration tutorial: http://www.cnblogs.com/bobliu/archive/2012/08/05/2590694.html; </H3>        <olclass= "Round">                       <Liclass= "One">                                <VideoID= "Video"width= " the"Height= "+"AutoPlay></Video>                <inputtype= "button"value= "Photo Button"ID= "Snap" />            </Li>            <Liclass= "both">                <CanvasID= "Canvas"width= " the"Height= "+"></Canvas>            </Li>        </ol>    </ Section></Div>

<script type= "Text/javascript" >varCanvas = document.getElementById ("Canvas"); varContext = Canvas.getcontext ("2d"); varVideo = document.getElementById ("video"); $ (document). Ready (function() {videoobj= {Video:true }; varErrback =function(Error) {Console.log ("Video Capture Error:", Error.code);            }; if(Navigator.getusermedia) {// StandardNavigator.getusermedia (Videoobj,function(stream) {video.src=Window.webkitURL.createObjectURL (stream);                Video.play ();            }, Errback); } Else if(Navigator.webkitgetusermedia) {//webkit-prefixedNavigator.webkitgetusermedia (Videoobj,function(stream) {video.src=window.                    Url.createobjecturl (stream);                Video.play ();            }, Errback); }            Else if(Navigator.mozgetusermedia) {//firefox-prefixedNavigator.mozgetusermedia (Videoobj,function(stream) {Video.mozsrcobject=stream;                Video.play ();            }, Errback);            }; $("#snap"). On ("click",function() {context.drawimage (video,0, 0, 640, 480);        }); });</script>

Google Browser high version to be compatible with the above code, you must deploy the project to HTTPS

HTTPS and IIS7.5 deployment tutorial can see so classmate's blog: http://www.cnblogs.com/bobliu/archive/2012/08/05/2590694.html;

I did a test demo click to download

HTML5 call native webcam compatible with Google Chrome version, Google Chrome low version, Firefox browser

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.