How to access phone-gap-media-stream from Cordova Webview ios

207 Views Asked by At

I would like to know how to use cordova plugins from webview. I have an existing website that displays the media stream using:

navigator.mediaDevices.getUserMedia({
      'audio': false,
      'video': {
          facingMode: 'environment'
      }
  }).then(function(mediaStream) {
   // Do what you want with
    
  });

I'm trying to implement a Cordova app that uses webview to visit this website. It has to support Android and ios. I managed to display the video stream on my Android cordova webview without changing any code on the website.

To make it happen on ios, I installed phonegap-plugin-media-stream in my cordova app. But I coundn't trigger the plugin from webview. When I visit the website, the app returns the error below:

TypeError: undefined is not an object (evaluating 'navigator.mediaDevices.getUserMedia')

I wonder how to trigger the phonegap media stream from webview. Is there anything I missed?

Is there a way to use cordova plugins from webview? The ios app has been granted the permission to camera. My website was not implemented to support cordova and I would love to know your thoughts. Thanks!!

0

There are 0 best solutions below