Web HTML5 calling the camera's code

Source: Internet
Author: User

<Html><Head><Title&GT;HTML5 call camera to take pictures</Title><StyleType= "Text/css">#camera{Width:640px;Height:525px;Position:Fixed;Border:1px solid #f0f0f0;-moz-border-radius:4px 4px 0 0;-webkit-border-radius:4px 4px 0 0;Border-radius:4px 4px 0 0;-moz-box-shadow:0 0 4px Rgba (0,0,0,0.6);-webkit-box-shadow:0 0 4px Rgba (0,0,0,0.6);Box-shadow:0 0 4px Rgba (0,0,0,0.6);}#buttons{Text-align:Center;}. btn{Width:99px;Height:38px;Line-height:32px;Margin:0px 4px 0px 0px;Border:1px solid #fff;-moz-border-radius:5px;/*Gecko Browsers*/-webkit-border-radius:5px;/*Webkit Browsers*/Border-radius:5px;/*Syntax*/Cursor:Default;Text-align:Center;Font-size:14px;Color:#fff;}. btn_blue{Background-color:#5CACEE;}. btn_green{Background-color:#00EE00;}. Hidden{Display:None}</Style></Head><Body><DivId= "Camera"><DivId= "Contentholder"><VideoId= "Video"Width= "640"Height= "480"AutoPlay></Video><CanvasStyle= "Display:none;"Id= "Canvas"Width= "640"Height= "480"></Canvas></Div><DivId= "Buttons"><buttonId= "Btn_snap"Class= "Btn Btn_blue"> Photography</button><buttonId= "Btn_cancel"Class= "Btn Btn_blue"Style= "Display:none;"> Cancel</button><buttonId= "Btn_upload"Class= "Btn Btn_green"Style= "Display:none;"> Upload</button></Div></Div></Body></Html><ScriptType= "Text/javascript">//Adding event listenersWindow.addeventlistener ("domcontentloaded",function() {//Get elements, create settings, and moreVarCanvas=document.getElementById ("Canvas"), Context=Canvas.getcontext ("2d"), video=document.getElementById ("Video"), Videoobj={"Video":True}, Errback=function(Error) {Console.log ("Video Capture Error:", Error.code); };//Add a video ListenerIf(Navigator.getusermedia) {//StandardNavigator.getusermedia (Videoobj,function(stream) {VIDEO.SRC=Stream Video.play (); }, Errback); }ElseIf(Navigator.webkitgetusermedia) {//WebKit PrefixNavigator.webkitgetusermedia (Videoobj,function(stream) {VIDEO.SRC=Window.webkitURL.createObjectURL (stream); Video.play (); }, Errback); }ElseIf(Navigator.mozgetusermedia) {//Firefox prefixesNavigator.mozgetusermedia (Videoobj,function(stream) {VIDEO.SRC=Window. Url.createobjecturl (stream); Video.play (); }, Errback); }Else{Alert ("Browser does not support html5!");//Console.log (' Your browser not support Getusermedia ');} document.getElementById ( "btn_snap" ). AddEventListener ( "click  " function () {context.drawimage (video, 0 0640 480); }); }, false); </script>  

Web HTML5 calling the camera's code

Related Article

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.