【问题标题】:Enable webRTC in cordova webview在科尔多瓦 webview 中启用 webRTC
【发布时间】:2016-12-02 12:46:07
【问题描述】:

我的科尔多瓦应用中有类似的东西

document.addEventListener("deviceready", onDeviceReady, false);

function onDeviceReady() {
        window.location.href = 'https://mobile.xxx.com';                    
}

现在我需要在这个网站上使用 webRTC。当我在移动浏览器(chrome 54.0.2840.85)中运行它时工作正常。

但是,当我使用 apk 时,webview 不会加载 webRTC 功能,如相机或微型。

因此,在移动浏览器中它可以正常工作,在 webview 中 rtc 将无法正常工作。

这就是我在 config.xml 中的内容

<content src="index.html" />

<access origin="https://mobile.xxx.com" /> 
<allow-navigation href="https://mobile.xxx.com" />
<allow-intent href="https://mobile.xxx.com" />

<plugin name="cordova-plugin-network-information"       version="1.3.0"     source="npm" />
<plugin name="cordova-plugin-splashscreen"              version="4.0.0"     source="npm" />
<plugin name="cordova-plugin-whitelist"                 version="1.3.0"     source="npm" />
<plugin name="cordova-plugin-dialogs"                   version="1.3.0"     source="npm" />
<plugin name="cordova-plugin-statusbar"                 version="2.2.0"     source="npm" />

<preference name="StatusBarOverlaysWebView"   value="false" />
<preference name="phonegap-version"           value="cli-6.3.0" />
<preference name="permissions"                value="none"/>
<preference name="target-device"              value="universal"/>
<preference name="fullscreen"                 value="true"/>
<preference name="show-splash-screen-spinner" value="true" /> 
<preference name="stay-in-webview"            value="true" />    
<preference name="orientation"            value="portrait" /> 
<preference name="loadUrlTimeoutValue"        value="700000" />

已经尝试过crosswalk,但同样的问题。如何在科尔多瓦 webview 中拥有 webrtc? 澄清一下,我只是在寻找一个功能演示。

【问题讨论】:

  • 你用的是什么版本的人行横道?
  • @johnborges 已经尝试过使用&lt;plugin name="cordova-plugin-crosswalk-webview" /&gt;&lt;plugin name="cordova-plugin-crosswalk-webview-pgb-adapt" source="npm" version="1.4.0-dev-5"/&gt;

标签: android cordova webview phonegap-plugins phonegap-build


【解决方案1】:

我不确定您正在使用哪些 WebRTC 特定功能,但大多数移动浏览器尚不完全支持它。见here

【讨论】:

  • 正如我所说的,相机/微型。
【解决方案2】:

据我从 https://developer.mozilla.org/en-US/docs/Web/API/WebRTC_API/Taking_still_photos 了解到,要访问我们应该制作的媒体 navigator.mediaDevices.getUserMedia

对于移动应用程序,您必须在 config.xml 中指定与您正在使用的摄像头或麦克风相关的权限。

用于媒体访问

<plugin name="cordova-plugin-media-capture" spec="1.4.0">
    <variable name="CAMERA_USAGE_DESCRIPTION" value="To take videos"/>
    <variable name="MICROPHONE_USAGE_DESCRIPTION" value="To record voice while taking videos"/>
    <variable name="PHOTO_LIBRARY_USAGE_DESCRIPTION" value="To provide photo browsing."/>
</plugin>

用于相机访问

<plugin name="cordova-plugin-camera" spec="2.3.0">
    <variable name="CAMERA_USAGE_DESCRIPTION" value="To take photos"/>
</plugin>

有关在移动应用程序中使用上述插件的更多详细信息,请参阅: https://github.com/apache/cordova-plugin-camera
https://github.com/apache/cordova-plugin-media-capture

【讨论】:

  • 谢谢,但即使这样,我的流也处于非活动状态。 stream.oninactive = function() { console.log('Stream inactive'); };
  • @user455318 你发现了吗?
猜你喜欢
  • 2021-03-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-08-30
  • 1970-01-01
相关资源
最近更新 更多