4

I am trying to build a video call application using Peerjs. So the video call will be displayed on the web view using html and javascript in the assest folder. The peerjs code is deployed on heroku and is working perfectly on web browser.

I am getting this error while connecting to video. Basically the other persons video is not loading.

E/chromium: [ERROR:web_contents_delegate.cc(218)]WebContentsDelegate::CheckMediaAccessPermission: Not supported.

This is the code i am using for setting up the webview

        binding.webView.settings.mediaPlaybackRequiresUserGesture = false
        binding.webView.settings.safeBrowsingEnabled = true
        binding.webView.settings.allowFileAccess = true
        binding.webView.addJavascriptInterface(VideoInterface(this), "Android")

        val cookieManager: CookieManager = CookieManager.getInstance()
        cookieManager.setAcceptThirdPartyCookies(binding.webView, true)

        @TargetApi(Build.VERSION_CODES.LOLLIPOP)
        binding.webView.webChromeClient = object: WebChromeClient() {
            override fun onPermissionRequest(request: PermissionRequest?) {
                request?.grant(request.resources);
            }
        }
        safeBrowsingIsInitialized = false

        if (WebViewFeature.isFeatureSupported(WebViewFeature.START_SAFE_BROWSING)) {
            WebViewCompat.startSafeBrowsing(root.context, ValueCallback<Boolean> { success ->
                safeBrowsingIsInitialized = true
                if (!success) {
                    Log.e("MY_APP_TAG", "Unable to initialize Safe Browsing!")
                }
            })
        } 

This is my manifest

   <uses-permission android:name="android.permission.CAMERA" />
   <uses-permission android:name="android.permission.RECORD_AUDIO" />

   <uses-permission android:name="android.webkit.PermissionRequest" />
   <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" /> 

  • Do you find any solution – Hitesh Mar 11 '22 at 12:45
  • this could happen if your URL is not `https://`. – Alex Cohn Mar 21 '22 at 18:09
  • @AlexCohn I am actually displaying an html file and the code related to it, is in the assets folder. It is deployed on heroku too. – Anam Ansari Mar 23 '22 at 13:30
  • Yes, rendering local HTML could cause this. – Alex Cohn Mar 23 '22 at 13:53
  • @AlexCohn Is there any way to remove the error, as i need the html file too – Anam Ansari Mar 24 '22 at 14:16
  • You can try to set [baseUrl](https://stackoverflow.com/a/29361318/192373). I have never tried this approach to handle camera. Whenever I use Peerjs, I have some server side that is configured to handle **https://** correctly, so I put my HTML there. – Alex Cohn Mar 25 '22 at 14:33
  • @AlexCohn I tried baseUrl, but its not working. It would help if you can show me a snippet of how you handled https:// on server side. – Anam Ansari Mar 25 '22 at 15:53
  • See also [android WebView webRTC error CheckMediaAccessPermission: Not supported](https://stackoverflow.com/a/69834636/192373) – Alex Cohn Mar 27 '22 at 09:45
  • Where can I find description about ```android.webkit.PermissionRequest```? I have not seen this in manifest permission, and only use it in ```WebChromeClient```' s ```onPermissionRequest``` callback. – Krahmal Apr 26 '22 at 03:40

1 Answers1

0

In manifest add android:usesCleartextTraffic="true"

override fun onPermissionRequest(request: PermissionRequest?) {
                runOnUiThread {
                    request?.grant(request.resources)
                }
            }
Sujith S Manjavana
  • 1,417
  • 6
  • 33
  • 60