HTML and CSS Reference
In-Depth Information
<br />
<button id="buttonShoot" class="horizontalBtn">Take a picture</button>
<br />
</div>
Basically, the webcam application consists of a button that triggers the webcam and an
IMG
element where users will view the captured image. The final preliminary step is to add a handler for
the
click
event for the Take A Picture button. Open the
instantPhotoApp.js
file and type the following
code:
instantPhotoApp.init = function () {
document.getElementById("buttonShoot")
.addEventListener("click", instantPhotoApp.takePicture);
};
instantPhotoApp.takePicture = function () {
// Some more code here
}
Now, you're all set and ready to tackle the webcam API.
Checking the webcam capability
Code is not allowed to freely access the webcam without explicit user permission. For this reason, to
give your app a chance to successfully use the webcam you must first declare your intention to use it.
As shown in Figure 12-1, double-click the manifest file you have in the project and select the
Capabilities tab from the subsequent view.
FIGURE 12-1
Enabling the capability that gives your code the ability to access the webcam programmatically.
Search WWH ::
Custom Search