Rise Of Html5 Over Flash and Silverlight
Posted By : Sachin Arora | 28-Jan-2018
The rise of HTML5 has brought a surge change to access device hardware. For any years audio/video capture is relying on the browser plugins like Flash and Silverlight, but html5 has come to the rescue by introducing high-level javascript apis with underlying hardware capabilities.This API is amazing for both developers and users as developers can now access both audio and video with single function call while the users don't need to install any additional softwares, from a users point of view it means a decrease in time to start using this feature an increased use of software by non-tech savvy people. The support for the API is good on a desktop but poor on mobiles.
The API exposes only one method ie. getUserMedia(), which belongs to the window.navigator, the method takes its parameters an object of constraints, a failure callback, and a success callback. The constraint parameter may have one or both the properties audio and video. These properties take in boolean value true means request the stream either audio or video and false means do not stream.
We can also provide extra fields in the parameters as for good resolution of video we can provide minHeight, minWidth, minFrameRate etc.
HTML5 has come up with an API navigator.getusermedia() to access the user's camera and microphone.
Syntax for using getusermedia() api:
navigator.getUserMedia(constraints, successCallback, errorCallback);
Simple example for using getusermedia() api:
navigator.getUserMedia = navigator.getUserMedia ||
navigator.webkitGetUserMedia ||
navigator.mozGetUserMedia;
if (navigator.getUserMedia) {
navigator.getUserMedia({ audio: true, video: { width: 1280, height: 720 } },
function(stream) {
var video = document.querySelector('video');
video.srcObject = stream;
video.onloadedmetadata = function(e) {
video.play();
};
},
function(err) {
console.log("The following error occurred: " + err.name);
}
);
} else {
console.log("getUserMedia not supported");
}
So this is how html5 has helped us to access media hardware using these powerful api's.
Cookies are important to the proper functioning of a site. To improve your experience, we use cookies to remember log-in details and provide secure log-in, collect statistics to optimize site functionality, and deliver content tailored to your interests. Click Agree and Proceed to accept cookies and go directly to the site or click on View Cookie Settings to see detailed descriptions of the types of cookies and choose whether to accept certain cookies while on the site.
About Author
Sachin Arora
Sachin is ambitious and hardworking individual with broad skills,He have the capabilities to build captivating UI applications . One of his key strength is building a strong bond with the team in order to deliver the best results on time .