Android Question WebRTC

Yvon Steinthal

Active Member
Licensed User
Longtime User
Hello,

I am trying to use WebRTC to stream video from an external Webcam on my mini computer that is plugged to a TV.

And when i use a webview to access the webrtc website it mentions that i do not have the permissions...

"Permissions have not been granted to use your camera and microphone, you need to allow the page access to your devices in order for the demo to work."

getUserMedia error: PermissionDeniedError

Any clues?

Y.

PS: I seem to need to use this:

Code: Copy
mWebView.setWebChromeClient(new WebChromeClient() {
@Override
public void onPermissionRequest(PermissionRequest request) {
request.grant(request.getResources());
}
});
 
Last edited:
You can use this code:
Code: Copy
Sub Activity_Create(FirstTime As Boolean)
   Activity.LoadLayout("1")
   Dim jme As JavaObject
   jme.InitializeContext
   jme.RunMethod("SetWebChrome", Array(WebView1))
End Sub

#if java

import android.widget.*;
import android.webkit.*;
public void SetWebChrome(WebView wv) {
   wv.setWebChromeClient(new WebChromeClient() {
     @Override
     public void onPermissionRequest(PermissionRequest request) {
       BA.Log("onPermissionRequest");
       request.grant(request.getResources());
     }
   });
}
#End If
You will also need to add the permissions to your app with AddPermission in the manifest editor.
 
Upvote 0
Thank you Erel, i will try this out and post my success / failures.

EDIT:
It works as intended, great help from you Erel, always appreciated! Keep up the good work and the awesome support.
 
Last edited:
Upvote 0
I have a follow up question. After several tests i realized the connection between two webrtc users cuts off because of the Browser of the Mini-PC i am using. Is there a way for the webview to be updated? (WebRTC works well on the Chrome browser but not on the webview ???)
 
Upvote 0
I have a follow up bug that i can't seem to grasp. In debug and on release on my samsung tablet, i am able to have a video chat using WebRTC without a hiccup.

On my mini-PC everything works until i receive the stream from the other party, and which point the video freezes and the app crashes. Any permissions i should look into to allow stream coming in?

Thanks

Y.
 
Last edited:
Upvote 0
Quite an easy feat, here's an example:

https://appr.tc/r/opto1481033879587

And i give the same url to my webview and my chrome browser, and they join in a room...

My b4a code is as follows:

Code: Copy
     Dim jme As JavaObject
     jme.InitializeContext
     jme.RunMethod("SetWebChrome", Array(CamView))
    
    
    
     videofeedcount = DateTime.Now

     isFeedOn = True
     Dim url As String = "https://appr.tc/r/opto"&videofeedcount
     ToastMessageShow(videofeedcount,False)
     CamView.LoadUrl(url)
     Activity.AddView(CamView,Activity.Width/4,Activity.Height/4,Activity.Width/2,Activity.Height/2)

videofeedcount is just a variable to never open the same "room"


EDIT: For anyone who's curious, i ended up building my own server with a WebRTC, node.js support and it worked as intended... im just missing some sound now...
 
Last edited:
Upvote 0
Back
Top