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.

About Author

Author Image
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 .

Request for Proposal

Name is required

Comment is required

Sending message..