WebView WebRTC not working

試著忘記壹切 提交于 2019-11-29 18:26:33

问题


I'm trying to show WebRTC chat in WebView. Related to this documentation WebView v36 supports WebRTC. For my test i'm using device with Chrome/39.0.0.0 and added permissins to manifest:

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

but when entered into chat see chromium error in the log (device doesn't show \ translate anything, only 'loading' progress bar):

W/AudioManagerAndroid: Requires MODIFY_AUDIO_SETTINGS and RECORD_AUDIO
W/AudioManagerAndroid: No audio device will be available for recording
E/chromium: [ERROR:web_contents_delegate.cc(178)] WebContentsDelegate::CheckMediaAccessPermission: Not supported.
E/chromium: [ERROR:web_contents_delegate.cc(178)] WebContentsDelegate::CheckMediaAccessPermission: Not supported.
W/AudioManagerAndroid: Requires MODIFY_AUDIO_SETTINGS and RECORD_AUDIO
W/AudioManagerAndroid: No audio device will be available for recording
D/ChromiumCameraInfo: Camera enumerated: front

tested on real device, Android 5.1.1


回答1:


additional request for permissions is needed

webView.setWebChromeClient(new WebChromeClient(){
        @TargetApi(Build.VERSION_CODES.LOLLIPOP)
        @Override
        public void onPermissionRequest(final PermissionRequest request) {
                request.grant(request.getResources());
        }
    });

update but it not working for audio capture

UPDATE found working google-sample code here



来源:https://stackoverflow.com/questions/38917751/webview-webrtc-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!