美文网首页
WebRTC支持

WebRTC支持

作者: cain07 | 来源:发表于2023-03-08 09:12 被阅读0次

    WebRTC****支持

    报错:Webcam Error
    navigator.mediadevices.getusermedia not present in your browser

    解决办法:

    // 重新WebChromeClient
    
    public class MWebChromeClient extends WebChromeClient {
    
        /**
    
         * 支持WebRTC
    
         * @param request
    
         */
    
        @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
    
        @Override
    
        public void onPermissionRequest(PermissionRequest request) {
    
            request.grant(request.getResources());
    
        }
    
    }
    

    Ref:

    https://github.com/oauth-io/oauth-android/issues/2

    HTTPS SSL****证书报错问题
    报错:TAG: X509Util - Failed to validate the certificate chain
    error: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.

    解决办法:

    // 重新WebViewClient
    public class MWebViewClient extends WebViewClient {
        /**
    
         * 解决SSL证书错误问题
    
         * @param view
    
         * @param handler
    
         * @param error
    
         */
    
        @Override
    
        public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
    
            handler.proceed();
    
        }
    
    }
    

    Ref:
    https://stackoverflow.com/questions/22376202/camera-not-opening-in-webview
    https://github.com/marcusbelcher/android-getUserMedia-test

    https://blog.csdn.net/chenli_001/article/details/79633761

    总结:动态设置:setWebChromeClient(@Nullable WebChromeClient client)
    当H5获取对应权限的时候,会走 onPermissionRequest(PermissionRequest request)回调,
    这个时候客户端Check 下有没有该动态权限,如果没有就动态获取权限,然后再调用:
    request.grant(request.getResources());
    动态给H5授权,这样H5就可以获取到动态的权限,实现对应的功能了

    兼容性问题
    https://blog.magicdu.cn/984.html

    相关文章

      网友评论

          本文标题:WebRTC支持

          本文链接:https://www.haomeiwen.com/subject/jwnnldtx.html