登录
    Technology changes quickly but people's minds change slowly.

腾讯云TRTC 在webview 下无法使用的问题 ,报 CheckMediaAccessPermission: Not supported.

技术宅 破玉 2486次浏览 0个评论

    前端写了个vue 版本的语音通话,采用的腾讯的TRTC SDK,本地浏览器调试正常,但是集成到webview 中后,通话接听后挂断,于是连Android studio查看了下 问题,一直报 “CheckMediaAccessPermission: Not supported.” 集成方式是自己手动写的webview 加载
原始代码如下:

  LinearLayout view=findViewById(R.id.test);
            mAgentWeb = AgentWeb.with(this)
                    .setAgentWebParent((LinearLayout) view, new LinearLayout.LayoutParams(-1, -1))
                    .useDefaultIndicator()
                    .createAgentWeb()
                    .ready()
                    .go("file:///android_asset/index.html#/");
            mAgentWeb.getJsInterfaceHolder().addJavaObject("psycloudapp",new PsyCloudVoice(this));
            IAgentWebSettings agentWebSettings = mAgentWeb.getAgentWebSettings();
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
                agentWebSettings.getWebSettings().setSafeBrowsingEnabled(false);
            }
            agentWebSettings.getWebSettings().setMediaPlaybackRequiresUserGesture(false);
            agentWebSettings.getWebSettings().setDomStorageEnabled(true);

这个错误,开始猜测是没有申请到语音的权限。
于是查找问题,按照这个文章修改了下配置 https://stackoverflow.com/questions/38917751/webrtc-error-inside-chromium-webview-checkmediaaccesspermission-not-supported

  LinearLayout view=findViewById(R.id.test);
            mAgentWeb = AgentWeb.with(this)
                    .setAgentWebParent((LinearLayout) view, new LinearLayout.LayoutParams(-1, -1))
                    .useDefaultIndicator()
                    .setWebChromeClient(mWebChromeClient)
                    .createAgentWeb()
                    .ready()
                    .go("file:///android_asset/index.html#/");
            mAgentWeb.getJsInterfaceHolder().addJavaObject("psycloudapp",new PsyCloudVoice(this));
            IAgentWebSettings agentWebSettings = mAgentWeb.getAgentWebSettings();
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
                agentWebSettings.getWebSettings().setSafeBrowsingEnabled(false);
            }
            agentWebSettings.getWebSettings().setMediaPlaybackRequiresUserGesture(false);
            agentWebSettings.getWebSettings().setDomStorageEnabled(true);

  private WebChromeClient mWebChromeClient=new WebChromeClient(){
        @Override
        public void onPermissionRequest(PermissionRequest request) {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
                String[] resources = request.getResources();
                request.grant(resources);
            }
        }
    };

结果还是不行,于是去翻了下腾讯的官方文档 https://github.com/LiteAVSDK/TRTC_Web/tree/main/base-react-next ,发现这样一段话

由于 H.264 版权限制,华为系统的 Chrome 浏览器和以 Chrome WebView 为内核的浏览器均不支持 TRTC 的 Web 版 SDK 的正常运行。

于是在webview 中打开如下网址检测了支持度
https://web.sdk.qcloud.com/trtc/webrtc/demo/detect/index.html
发现不支持 H264
于是乎只能更换 wbeview 内核,由于是腾讯的服务,所以更换为腾讯的X5 内核,具体更换流程,腾讯官方给的很清楚,参考 https://x5.tencent.com/docs/access.html


华裳绕指柔, 版权所有丨如未注明 , 均为原创|转载请注明腾讯云TRTC 在webview 下无法使用的问题 ,报 CheckMediaAccessPermission: Not supported.
喜欢 (14)
发表我的评论
取消评论
表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址