Reputation: 33
I'm working on a WebRTC webview project. I'm playing a video with camera and microphone permission. The Video works on emulator but not on phone.Buttons come in, camera turns on but the video does not appear. Leaves on white screen.
API levels are the same both API 28.
My codes here
initview()
mWebView = (WebView) findViewById(R.id.wb);
mWebView.requestFocus();
mWebView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
WebSettings settings = mWebView.getSettings();
settings.setDomStorageEnabled(true);
mWebView.setWebViewClient(new MyWebViewClient());
WebChromeClientCustomPoster chromeClient = new WebChromeClientCustomPoster();
mWebView.setWebChromeClient(chromeClient);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.setWebChromeClient(new WebChromeClient() {
@Override
public void onPermissionRequest(final PermissionRequest request) {
MainActivity.this.runOnUiThread(new Runnable(){
@TargetApi(Build.VERSION_CODES.M)
@Override
public void run() {
request.grant(request.getResources());
}// run
});// MainActivity
}// onPermissionRequest
});// setWebChromeClient
mWebView.loadUrl("http://google.com");
Upvotes: 0
Views: 315
Reputation: 33
I found the answer. I added
mWebView.getSettings().setMediaPlaybackRequiresUserGesture(false)
and application works fine.
Upvotes: 1