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."
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.
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 ???)
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?
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:
B4X:
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...