JSFoo 2014

JavaScript as the centerpiece of a complex web stack


Using javascript to access Camera functions

Submitted Jun 13, 2014

Using javascript to access Camera functions

This topic shows you the simplest way to capture a photo or video from your embedded or attached camera, by using the JS. This project will launche a full-screen dialog that presents a camera UI, and enables you to capture a photo or video with as little as one method call.

Objective: Capture a photo or video from a webcam.


simple description

  1. Open Visual Studio

Open an instance of Visual Studio.
2. Create a new project

In the New Project dialog box, choose a blank application from the JavaScript project types.
3. Insert the app JavaScript and HTML

Open your file Default.html and copy the following HTML into this file (replacing its original contents).

courtesy : msdn
but this is the best description i can give

<!DOCTYPE html>
<!-- WinJS references -->
<link rel=“stylesheet” href=“/winjs/css/ui-dark.css” />
<script src=“/winjs/js/base.js”></script>
<script src=“/winjs/js/wwaapp.js”></script>
<!-- WinWebApp1 references -->
<link rel=“stylesheet” href=“/css/default.css” />

<script type = “text/javascript” >

// Takes a photo using the default JPEG format.
function takepicture() {
var captureUI = new Windows.Media.Capture.CameraCaptureUI();
captureUI.captureFileAsync(Windows.Media.Capture.CameraCaptureUIMode.photo).then(function (capturedItem) {
if (capturedItem) {
document.getElementById(“message”).innerHTML = “User captured a photo.”
else {
document.getElementById(“message”).innerHTML = “User didn’t capture a photo.”
<input type=“button” onclick=“takepicture()” value=“Take a Picture” /><br />
<span id=“message”></span>

Speaker bio

I am Vigneshwer Dhinakaran presently studying 3rd year in ECE at rajagiri college, ernakulam and also a founder of a startup company altroid. To be short and sweet I am an Innovative Engineer with an artistic perception of technology. I hold sun certified certificates on core java and J2EE .Have developed around 6 apps in various platforms ,and created around 10 websites. I have been as speaker and participant in various paper presentation competitons ,IEEE conferences ,pitching session at startup village and have taken workshops in web and app development for Rset ieee club .I am a active mozillian from mozilla kerala and have been involved in various mozilla activities & project contributions.

detailed session presentation will be drafted if selected.


{{ gettext('Login to leave a comment') }}

{{ gettext('Post a comment…') }}
{{ gettext('New comment') }}
{{ formTitle }}

{{ errorMsg }}

{{ gettext('No comments posted yet') }}

Hosted by

JSFoo is a forum for discussing UI engineering; fullstack development; web applications engineering, performance, security and design; accessibility; and latest developments in #JavaScript. Follow JSFoo on Twitter more