在具有代号1的WebView上实现WebRTC [英] Implementing WebRTC on WebView with Codename One

查看:323
本文介绍了在具有代号1的WebView上实现WebRTC的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个应用程序,需要使用Android的WebView包含WebRTC。根据这篇文章:[ https://developer.chrome.com/multidevice/webview/overview ] 从WebView v36开始完全受支持。 (我正在Android 5.1.1 / Chrome 54 / Mobile Safari 537.36上进行测试。我确认它可以在独立的Chrome浏览器上使用。)

I'm developing an app which I need to include WebRTC using the WebView of Android. According to this article: [https://developer.chrome.com/multidevice/webview/overview] it is fully supported since WebView v36. (I'm testing on an Android 5.1.1 / Chrome 54 / Mobile Safari 537.36. And I confirm that it works on the standalone Chrome browser).

到目前为止,可以查看WebRTC。

As of now, viewing of WebRTC works.

但是,广播(从摄像机捕获视频并将其发送到服务器)不起作用。注意:它可以在同一Android上的独立Chrome上运行。

However, broadcasting (capturing video from the camera and sending it to the server) does not work. Note: it works on the standalone Chrome on the same Android.

我在codenameone_settings.properties文件中包含了所有这些权限:

I've included all these permissions in the codenameone_settings.properties file:

android.xpermissions=<uses-permission android:name="android.permission.CAMERA" android:required="true"/>\
  <uses-permission android:name="android.permission.RECORD_AUDIO" android:required="true" />\
  <uses-permission android:name="android.permission.INTERNET" android:required="true" />\
  <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:required="true" />\
  <uses-permission android:name="android.permission.CAMERA" android:required="true" />\
  <uses-feature android:name="android.hardware.audio.low_latency" android:required="true" />\
  <uses-feature android:name="android.hardware.audio.pro" android:required="true" />\
  <uses-feature android:name="android.hardware.microphone" android:required="true"/>\
  <uses-feature android:name="android.hardware.camera" android:required="true" />\
  <uses-feature android:name="android.hardware.camera.autofocus" android:required="true"/>\
  <uses-feature android:name="android.hardware.camera" android:required="true" />\
  <uses-feature android:name="android.hardware.camera.front" android:required="true" />




  1. 这是激活所有必要的Android权限的方式。

  2. 您认为是什么导致WebRTC无法正常运行?

WebView由

我知道Android代码已转换为本地代码,并且我相信有一种方法可以使其正常工作。谢谢!

I understand that Android code is translated to native code and I believe that there is a way to make it work. Thanks!

推荐答案

我只是看了几个示例( 此处,并且看来webview需要授予一些权限

I just took a look at a couple of examples (here and here, and it looks like the webview needs to grant some permissions in order to allow webrtc to work.

我已经做了一个对我们的Android端口进行的小改动,应允许您授予这些权限。您只需要指定允许权限的来源即可。您可以通过设置 android.WebView .grantPermissionsFrom显示属性,用于授予权限的URL(或以空格分隔的URL)。

I have made a small change to our Android port that should allow you to grant these permissions. You just need to specify the origin in which permissions should be allowed. You would do this by setting the "android.WebView.grantPermissionsFrom" display property to the URL (or space delimited URLs) that you want to grant the permissions on.

例如


Display.getInstance().setProperty(
        "android.WebView.grantPermissionsFrom", 
        "https://www.example.com/"
);

在应用程序的init()或start()方法中调用它。

Call this in your app's init() or start() method.

注意这些更改将在下一次服务器更新之前不可用。我不确定确切的时间是什么,因为新手训练营目前正在进行中。通常是每个星期五,但由于训练营,可能会推迟到5月的第一周。

NOTE These changes won't be available until the next server update. I'm not sure exactly when that will be since the bootcamp is underway right now. Usually it is every Friday, but it may be delayed until the first week of May due to the bootcamp.

这篇关于在具有代号1的WebView上实现WebRTC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆