I'm trying to launch camera on android 6.0.0 with Web APIs. Below is the piece of code which works perfectly on web browser.

```
    var constraints = {
                    video: true,
                    audio: false,
            }

    // get the media sources
    MediaStreamTrack.getSources(function(sourceInfos) {

            navigator.getUserMedia( constraints, function(stream){
                domElement.src = URL.createObjectURL(stream);
            }, function(error) {
                    console.error("Cant getUserMedia()! due to ", error);
            });
    });

```

I have bundled this piece of code into an apk with ionic framework. But on the phone, it displays a broken video playback image.

On further debugging I noticed "permission denied" error is thrown. I'm not exactly sure for which reason this error is thrown. I googled and have done all the solutions provided. But it has not worked for me.

If I try to build it via phoneGap, it shows NavigatorUserMediaError {name: "PermissionDeniedError", message: "Only secure origins are allowed (see: some URL).", constraintName: ""}

Could you please help me?