{"id":3180,"date":"2015-04-06T12:15:02","date_gmt":"2015-04-06T09:15:02","guid":{"rendered":"http:\/\/www.webcodegeeks.com\/?p=3180"},"modified":"2017-12-19T14:07:03","modified_gmt":"2017-12-19T12:07:03","slug":"html5-web-camera-example","status":"publish","type":"post","link":"https:\/\/www.webcodegeeks.com\/html5\/html5-web-camera-example\/","title":{"rendered":"HTML5 Web Camera Example"},"content":{"rendered":"<p>In this article I&#8217;ll present you how to use and access the visitor Web Camera.<\/p>\n<p>First we will present the API, then we will see an example to explain the HTML5 API usage.<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n[ulp id=&#8217;tgm4cmEWcKUikZNn&#8217;]<\/p>\n<h2>1. The history<\/h2>\n<p>The specification of the API that allows web pages to interact with user (visitor) camera (and\/or microphone) evolved many times.<\/p>\n<p>The story of accessing the user device started with the use of the html <code>&lt;input type=\"file\" \/&gt;<\/code> element and two attributes :<\/p>\n<ul>\n<li><code>accept<\/code>, this attribute allow to define which type of file the user can upload : <code>&lt;input<br \/>\ntype=\"file\" accept=\"image\/*;\" &gt;<\/code><\/li>\n<li><code>capture<\/code>, this attribute tells the browser to capture the media directly from a device.<\/li>\n<\/ul>\n<p>So at this age, the way you could retreive some data from the user device (camera, or microphone) was to handle the <code>change<\/code> event on the <code>&lt;input type=\"file\" \/&gt;<\/code> element, and to pass the <em>file<\/em> to the <em>&#8220;good&#8221;<\/em> element, canvas for video rendering, or an image element for image visualisation.<\/p>\n<p>The example below is inspired from the main <a href=\"http:\/\/dev.w3.org\/2009\/dap\/camera\/\" target=\"_blank\">Specification<\/a> :<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;input type=&quot;file&quot; accept=&quot;video\/*&quot; capture&gt;\r\n&lt;canvas&gt;&lt;\/canvas&gt;\r\n<\/pre>\n<p>And the JavaScript<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n\r\nvar input = document.querySelector('input&#x5B;type=file]');\r\n\r\ninput.addEventListener('change', function () {\r\n    var file = input.files&#x5B;0];\r\n    drawOnCanvas(file);\r\n};\r\n\r\nfunction drawOnCanvas(file) {\r\n\r\n   \/\/ We use the File APi to read the content of the input file element\r\n   var reader = new FileReader();\r\n\r\n    \/\/ On reader load with parse the content and draw it on Canvas\r\n    reader.onload = function (e) {\r\n        var dataURL = e.target.result,\r\n            c = document.querySelector('canvas'),\r\n            ctx = c.getContext('2d'),\r\n            img = new Image();\r\n\r\n        img.onload = function() {\r\n            c.width = img.width;\r\n            c.height = img.height;\r\n            ctx.drawImage(img, 0, 0);\r\n        };\r\n\r\n        img.src = dataURL;\r\n    };\r\n\r\n    \/\/ Load the file in reader ...\r\n    reader.readAsDataURL(file);\r\n}\r\n<\/pre>\n<p>This example uses the HTML File API to read, parse and display the video.<\/p>\n<blockquote><p><strong>Note:<\/strong> This implementation is not really supported anymore by browsers (on desktop), the<br \/>\nwould prefer the use of <code>navigator.gerUserMedia()<\/code>.<\/p><\/blockquote>\n<h2>2. The navigator.getUserMedia()<\/h2>\n<p>As with many of the HTML5 features, browser implementation may not be available in the user browser, so first we will need to check if we can use the particular feature.<\/p>\n<h3>2.1 Detect the feature &#8230;<\/h3>\n<p>All browsers created a specific function which can be used to retrieve the user media so we will need to create a wrapper function for accessing the user media :<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n    function userMedia(){\r\n        return navigator.getUserMedia = navigator.getUserMedia   ||\r\n                                    navigator.webkitGetUserMedia ||\r\n                                    navigator.mozGetUserMedia    ||\r\n                                    navigator.msGetUserMedia     || null;\r\n\r\n        }\r\n\r\n    ;\r\n\r\n    \/\/ Now we can use it\r\n    if( userMedia() {\r\n        \/\/ We can use the usermedia\r\n    } else {\r\n        \/\/ We can not use the user media.\r\n    }\r\n<\/pre>\n<p>The function <code>userMedia()<\/code> is used to check if the browser accepts the use of the user device. If it&#8217;s supported, the browser <em>prefixed<\/em> function, is assigned to the <code>navigator.gerUserMedia()<\/code>. Let see how to use the API.<\/p>\n<h3>2.2 The API<\/h3>\n<p>The <code>navigator.gerUserMedia()<\/code> accepts three parameters :<\/p>\n<ul>\n<li><code>constraints<\/code>, this parameter is required, and must be an object (a<br \/>\n<code>MediaStreamConstraints<\/code> object). This object is a simple Object with two members :<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n            {\r\n                audio:true, \/\/ A boolean to define if we need to access audio device\r\n                video:true \/\/ A boolean to define if we need to acces the video device\r\n            }\r\n        <\/pre>\n<\/li>\n<li><code>success<\/code>, this is a required parameter, and it must be a Function, that will be called if the after accessing the device(s).<\/li>\n<li><code>error<\/code>, this is an optional parameter, and if presents must be a Function, that will be called in case of errors while accessing the device(s).<\/li>\n<\/ul>\n<blockquote><p><strong>Note:<\/strong>  call to <code>navigator.gerUserMedia()<\/code> will prompt the user to accept (or not) the use of his device. The <code>success<\/code> callback, will be called just after the user accept. And the <em>error<\/em> function is called when error arrived or when the user does not accept the use of his device.<\/p><\/blockquote>\n<h3>2.3 The Constraints object<\/h3>\n<p>The Constraints object can be augmented to define more prerequisites on capturing video (such as video quality).<\/p>\n<p>The constraint is a <code>MediaTrackConstraints<\/code> object, define in the <a href=\"http:\/\/w3c.github.io\/mediacapture-main\/getusermedia.html#idl-def-MediaTrackConstraints\">API<\/a>.<\/p>\n<p>For example if you only want to capture HD video you can define those constraints :<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nvar hdVideoConstraints = {\r\n  video: {\r\n    mandatory: {\r\n      minWidth: 1280,\r\n      minHeight: 720\r\n    }\r\n  }\r\n};\r\n<\/pre>\n<p>The <a href=\"http:\/\/w3c.github.io\/mediacapture-main\/getusermedia.html#idl-def-MediaTrackConstraints\"><code>MediaTrackConstraints<\/code> API<\/a> will allow you to add constraints on elements like <code>aspectRatio<\/code> or <code>frameRate<\/code> or even <code>volume<\/code>. Have a look to the API definition to check how to use those constraints.<\/p>\n<blockquote><p>Remember the API is still in Draft &#8230;<\/p><\/blockquote>\n<h2>3. Display the Video<\/h2>\n<p>This example will display the video from the user webcam in the document :<\/p>\n<p>The HTML file :<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;!doctype html&gt;\r\n&lt;html lang=&quot;en&quot;&gt;\r\n&lt;head&gt;\r\n    &lt;meta charset=&quot;UTF-8&quot;&gt;\r\n    &lt;title&gt;Get User Media - example 1&lt;\/title&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n&lt;video id=&quot;v&quot;&gt;&lt;\/video&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n<p>And the javascript.<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n(function(){\r\n    function userMedia(){\r\n        return navigator.getUserMedia = navigator.getUserMedia ||\r\n        navigator.webkitGetUserMedia ||\r\n        navigator.mozGetUserMedia ||\r\n        navigator.msGetUserMedia || null;\r\n\r\n    }\r\n\r\n    \/\/ Now we can use it\r\n    if( userMedia() ){\r\n\r\n        var constraints = {\r\n            video: true,\r\n            audio:false\r\n        };\r\n\r\n        var media = navigator.getUserMedia(constraints, function(stream){\r\n            var v = document.getElementById('v');\r\n\r\n            \/\/ URL Object is different in WebKit\r\n            var url = window.URL || window.webkitURL;\r\n\r\n            \/\/ create the url and set the source of the video element\r\n            v.src = url ? url.createObjectURL(stream) : stream;\r\n\r\n            \/\/ Start the video\r\n            v.play();\r\n        }, function(error){\r\n            console.log(&quot;ERROR&quot;);\r\n            console.log(error);\r\n        });\r\n    } else {\r\n        console.log(&quot;Browser does not support WebCam integration&quot;);\r\n    }\r\n})();\r\n<\/pre>\n<p>This will example is quite simple, and the code seems to be self documented.<\/p>\n<h2>4. Take A picture<\/h2>\n<p>As we used the camera to display the video, we can also use it in order to take some pictures.<\/p>\n<p>In order to take a screenshot of the video we will have to use the canvas Api, lets see the example.<\/p>\n<h3>4.1 The Html<\/h3>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;!doctype html&gt;\r\n&lt;html lang=&quot;en&quot;&gt;\r\n&lt;head&gt;\r\n    &lt;meta charset=&quot;UTF-8&quot;&gt;\r\n    &lt;title&gt;Get User Media - Photo&lt;\/title&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n&lt;button id=&quot;take&quot;&gt;Take a photo&lt;\/button&gt;&lt;br \/&gt;\r\n&lt;video id=&quot;v&quot;&gt;&lt;\/video&gt;\r\n&lt;canvas id=&quot;canvas&quot; style=&quot;display:none;&quot;&gt;&lt;\/canvas&gt;\r\n&lt;img src=&quot;http:\/\/placehold.it\/300&amp;text=Your%20image%20here%20...&quot; id=&quot;photo&quot; alt=&quot;photo&quot;&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n<p>I just added button, to take the picture.<\/p>\n<h3>4.2 The JavaScript<\/h3>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n;(function(){\r\n    function userMedia(){\r\n        return navigator.getUserMedia = navigator.getUserMedia ||\r\n        navigator.webkitGetUserMedia ||\r\n        navigator.mozGetUserMedia ||\r\n        navigator.msGetUserMedia || null;\r\n\r\n    }\r\n\r\n    \/\/ Now we can use it\r\n    if( userMedia() ){\r\n        var videoPlaying = false;\r\n        var constraints = {\r\n            video: true,\r\n            audio:false\r\n        };\r\n        var video = document.getElementById('v');\r\n\r\n        var media = navigator.getUserMedia(constraints, function(stream){\r\n\r\n            \/\/ URL Object is different in WebKit\r\n            var url = window.URL || window.webkitURL;\r\n\r\n            \/\/ create the url and set the source of the video element\r\n            video.src = url ? url.createObjectURL(stream) : stream;\r\n\r\n            \/\/ Start the video\r\n            video.play();\r\n            videoPlaying  = true;\r\n        }, function(error){\r\n            console.log(&quot;ERROR&quot;);\r\n            console.log(error);\r\n        });\r\n\r\n        \/\/ Listen for user click on the &quot;take a photo&quot; button\r\n        document.getElementById('take').addEventListener('click', function(){\r\n            if (videoPlaying){\r\n                var canvas = document.getElementById('canvas');\r\n                canvas.width = video.videoWidth;\r\n                canvas.height = video.videoHeight;\r\n                canvas.getContext('2d').drawImage(video, 0, 0);\r\n                var data = canvas.toDataURL('image\/webp');\r\n                document.getElementById('photo').setAttribute('src', data);\r\n            }\r\n        }, false);\r\n\r\n    } else {\r\n        console.log(&quot;KO&quot;);\r\n    }\r\n})();\r\n<\/pre>\n<p>As you can see I&#8217;ve only added a variable for capturing the video status (if it&#8217;s playing or not) <code>var videoPlaying = false;<\/code>.<\/p>\n<p>Then for taking the photo I added an event Listener on the button click ::<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\ndocument.getElementById('take').addEventListener('click', function(){ \/*...*\/});\r\n<\/pre>\n<p>When the user click on the button, if the video is playing, we, create draw the Video image in the canvas (even if the canvas is not visible) :<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\ncanvas.getContext('2d').drawImage(video, 0, 0);\r\n<\/pre>\n<p>Next, we create a <code>data<\/code> URL for define the image <code>src<\/code> attribute.<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\nvar data = canvas.toDataURL('image\/webp');\r\ndocument.getElementById('photo').setAttribute('src', data);\r\n<\/pre>\n<h2>5. Download<\/h2>\n<div class=\"download\"><strong>Download<\/strong><br \/>\nYou can download the full source code of this example here: <a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/03\/html5-webcam-example.zip\"><strong>HTML5 Webcam Example<\/strong><\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<p>In this article I&#8217;ll present you how to use and access the visitor Web Camera. First we will present the API, then we will see an example to explain the HTML5 API usage. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; [ulp id=&#8217;tgm4cmEWcKUikZNn&#8217;] 1. The history The specification of the API that allows web pages to &hellip;<\/p>\n","protected":false},"author":46,"featured_media":914,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[126],"class_list":["post-3180","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-html5","tag-webcam"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>HTML5 Web Camera Example<\/title>\n<meta name=\"description\" content=\"An example of how to access video or photo, from the user Web Camera, with HTML5 API.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.webcodegeeks.com\/html5\/html5-web-camera-example\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"HTML5 Web Camera Example\" \/>\n<meta property=\"og:description\" content=\"An example of how to access video or photo, from the user Web Camera, with HTML5 API.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.webcodegeeks.com\/html5\/html5-web-camera-example\/\" \/>\n<meta property=\"og:site_name\" content=\"Web Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webcodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2015-04-06T09:15:02+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2017-12-19T12:07:03+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/html5-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Remi Goyard\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@mimiz33\" \/>\n<meta name=\"twitter:site\" content=\"@webcodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Remi Goyard\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.webcodegeeks.com\/html5\/html5-web-camera-example\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/html5\/html5-web-camera-example\/\"},\"author\":{\"name\":\"Remi Goyard\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/ae15332f888fcdc376a8d4e03180e242\"},\"headline\":\"HTML5 Web Camera Example\",\"datePublished\":\"2015-04-06T09:15:02+00:00\",\"dateModified\":\"2017-12-19T12:07:03+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/html5\/html5-web-camera-example\/\"},\"wordCount\":1318,\"commentCount\":8,\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/html5\/html5-web-camera-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/html5-logo.jpg\",\"keywords\":[\"webcam\"],\"articleSection\":[\"HTML5\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.webcodegeeks.com\/html5\/html5-web-camera-example\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.webcodegeeks.com\/html5\/html5-web-camera-example\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/html5\/html5-web-camera-example\/\",\"name\":\"HTML5 Web Camera Example\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/html5\/html5-web-camera-example\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/html5\/html5-web-camera-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/html5-logo.jpg\",\"datePublished\":\"2015-04-06T09:15:02+00:00\",\"dateModified\":\"2017-12-19T12:07:03+00:00\",\"description\":\"An example of how to access video or photo, from the user Web Camera, with HTML5 API.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/html5\/html5-web-camera-example\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.webcodegeeks.com\/html5\/html5-web-camera-example\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/html5\/html5-web-camera-example\/#primaryimage\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/html5-logo.jpg\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/html5-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.webcodegeeks.com\/html5\/html5-web-camera-example\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.webcodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"HTML5\",\"item\":\"https:\/\/www.webcodegeeks.com\/category\/html5\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"HTML5 Web Camera Example\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"name\":\"Web Code Geeks\",\"description\":\"Web Developers Resource Center\",\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.webcodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webcodegeeks\",\"https:\/\/x.com\/webcodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/ae15332f888fcdc376a8d4e03180e242\",\"name\":\"Remi Goyard\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/caa839a88ba9d485eec370ff8e020c314f10fb2e4ddedb3424a4bf92198259b2?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/caa839a88ba9d485eec370ff8e020c314f10fb2e4ddedb3424a4bf92198259b2?s=96&d=mm&r=g\",\"caption\":\"Remi Goyard\"},\"description\":\"I'm a senior web architect. Passionated by new technologies, programming, devops tools, and agile methodologies. I really enjoy to coach, or teach, people who wants to learn programming, from beginners to skilled programmers. Involved in local developer communities, Java User Group, PHP User Group, or Javascript User Group, i like to share with others about experiences, news or business. Coding is FUN !\",\"sameAs\":[\"http:\/\/www.mimiz.fr\/\",\"http:\/\/fr.linkedin.com\/in\/remigoyard\/en\",\"https:\/\/x.com\/@mimiz33\"],\"url\":\"https:\/\/www.webcodegeeks.com\/author\/remi-goyard\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"HTML5 Web Camera Example","description":"An example of how to access video or photo, from the user Web Camera, with HTML5 API.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.webcodegeeks.com\/html5\/html5-web-camera-example\/","og_locale":"en_US","og_type":"article","og_title":"HTML5 Web Camera Example","og_description":"An example of how to access video or photo, from the user Web Camera, with HTML5 API.","og_url":"https:\/\/www.webcodegeeks.com\/html5\/html5-web-camera-example\/","og_site_name":"Web Code Geeks","article_publisher":"https:\/\/www.facebook.com\/webcodegeeks","article_published_time":"2015-04-06T09:15:02+00:00","article_modified_time":"2017-12-19T12:07:03+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/html5-logo.jpg","type":"image\/jpeg"}],"author":"Remi Goyard","twitter_card":"summary_large_image","twitter_creator":"@mimiz33","twitter_site":"@webcodegeeks","twitter_misc":{"Written by":"Remi Goyard","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.webcodegeeks.com\/html5\/html5-web-camera-example\/#article","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/html5\/html5-web-camera-example\/"},"author":{"name":"Remi Goyard","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/ae15332f888fcdc376a8d4e03180e242"},"headline":"HTML5 Web Camera Example","datePublished":"2015-04-06T09:15:02+00:00","dateModified":"2017-12-19T12:07:03+00:00","mainEntityOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/html5\/html5-web-camera-example\/"},"wordCount":1318,"commentCount":8,"publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/html5\/html5-web-camera-example\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/html5-logo.jpg","keywords":["webcam"],"articleSection":["HTML5"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.webcodegeeks.com\/html5\/html5-web-camera-example\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.webcodegeeks.com\/html5\/html5-web-camera-example\/","url":"https:\/\/www.webcodegeeks.com\/html5\/html5-web-camera-example\/","name":"HTML5 Web Camera Example","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/html5\/html5-web-camera-example\/#primaryimage"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/html5\/html5-web-camera-example\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/html5-logo.jpg","datePublished":"2015-04-06T09:15:02+00:00","dateModified":"2017-12-19T12:07:03+00:00","description":"An example of how to access video or photo, from the user Web Camera, with HTML5 API.","breadcrumb":{"@id":"https:\/\/www.webcodegeeks.com\/html5\/html5-web-camera-example\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.webcodegeeks.com\/html5\/html5-web-camera-example\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/html5\/html5-web-camera-example\/#primaryimage","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/html5-logo.jpg","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/html5-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.webcodegeeks.com\/html5\/html5-web-camera-example\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.webcodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"HTML5","item":"https:\/\/www.webcodegeeks.com\/category\/html5\/"},{"@type":"ListItem","position":3,"name":"HTML5 Web Camera Example"}]},{"@type":"WebSite","@id":"https:\/\/www.webcodegeeks.com\/#website","url":"https:\/\/www.webcodegeeks.com\/","name":"Web Code Geeks","description":"Web Developers Resource Center","publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.webcodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.webcodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.webcodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webcodegeeks","https:\/\/x.com\/webcodegeeks"]},{"@type":"Person","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/ae15332f888fcdc376a8d4e03180e242","name":"Remi Goyard","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/caa839a88ba9d485eec370ff8e020c314f10fb2e4ddedb3424a4bf92198259b2?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/caa839a88ba9d485eec370ff8e020c314f10fb2e4ddedb3424a4bf92198259b2?s=96&d=mm&r=g","caption":"Remi Goyard"},"description":"I'm a senior web architect. Passionated by new technologies, programming, devops tools, and agile methodologies. I really enjoy to coach, or teach, people who wants to learn programming, from beginners to skilled programmers. Involved in local developer communities, Java User Group, PHP User Group, or Javascript User Group, i like to share with others about experiences, news or business. Coding is FUN !","sameAs":["http:\/\/www.mimiz.fr\/","http:\/\/fr.linkedin.com\/in\/remigoyard\/en","https:\/\/x.com\/@mimiz33"],"url":"https:\/\/www.webcodegeeks.com\/author\/remi-goyard\/"}]}},"_links":{"self":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/3180","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/users\/46"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/comments?post=3180"}],"version-history":[{"count":0,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/3180\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media\/914"}],"wp:attachment":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media?parent=3180"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/categories?post=3180"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/tags?post=3180"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}