Hello @ @Janakiraman-P ,
It would seem that you need to use navigator.mediaDevices.getUserMedia() then the API should work.
It is not implemented yet in Chrome, but it works there if you use the official adapter.js WebRTC polyfill: https://jsfiddle.net/srn9db4h/
Example:
navigator.mediaDevices.getUserMedia({ video: true, audio: true })
.then(stream => video.srcObject = stream)
.catch(e => log(e.name + ": "+ e.message));
var log = msg => div.innerHTML += msg + "<br>";
Firefox and Edge support it natively FWIW.
Update: Chrome (50) appears to support this now. And Chrome 52 even supports srcObject
To access navigator.mediaDevices you must connect your site with HTTPS connection. There are no access this feature with HTTP
Direct access to the camera is a powerful feature. It requires consent from the user, and your site MUST be on a secure origin (HTTPS)
Although this is not recommended but still you can try this to test your project by disabling security for media.
chrome://flags/#unsafely-treat-insecure-origin-as-secure
you can add your IP and chrome will treat it as secure
You can check more details at WebRTC getUserMedia promise api support in Chrome and web fundamentals media capturing issues