2016-12-02 186 views
3

启用的WebRTC我有这样的事情在我的科尔多瓦应用在科尔多瓦的WebView

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,但同样的问题。我如何在cordova webview中使用webrtc?为了澄清,我只是在寻找一个功能演示。

+0

什么人行横道的版本你在用吗? – johnborges

+0

@johnborges已经尝试过使用''''''和<'plugin name =“cordova-plugin-crosswalk-webview-pgb-adapt”source =“npm”version =“1.4.0-dev-5”/>''' – user455318

回答

0

我不确定您使用的是什么WebRTC特定功能,但是对于大多数移动浏览器尚未完全支持。请参阅here

+0

正如我所说的,camera/micro。 – user455318

0

据我从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

+0

谢谢,但即使如此,我正在流无效。 '''stream.oninactive = function(){console.log('Stream inactive'); };'' – user455318