我在Nativescript上使用WebView来实现tokbox.js功能,前置摄像头可以工作,但是当尝试进行交换(publisher.cycleVideo())时,出现以下错误:
铬:[ERROR:web_contents_delegate.cc(204)] WebContentsDelegate :: CheckMediaAccessPermission:不支持。
其他Tokbox的功能有效,例如隐藏视频或静音音频,因此这是我在项目中拥有的代码示例:
this.webview = webargs.object;
if(isAndroid){
var TNSWebViewClient =
android.webkit.WebViewClient.extend({
shouldOverrideUrlLoading: function (view, url) {
if (url != null && url.startsWith("http://")) {
console.log(url);
// use openUrl form utils module to open the page in a browser
return true;
} else {
return false;
}
}
});
var TNSWebChromeClient =
android.webkit.WebChromeClient.extend({
onPermissionRequest: function (request) {
request.grant(request.getResources());
}
});
this.webview.android.getSettings().setDisplayZoomControls(false);
this.webview.android.getSettings().setBuiltInZoomControls(false);
this.webview.android.getSettings().setAllowFileAccessFromFileURLs(true);
this.webview.android.getSettings().setAllowUniversalAccessFromFileURLs(true);
this.webview.android.getSettings().setMediaPlaybackRequiresUserGesture(false);
this.webview.android.getSettings().setUseWideViewPort(true);
this.webview.android.getSettings().setDomStorageEnabled(true);
this.webview.android.setWebViewClient(new TNSWebViewClient());
this.webview.android.setWebChromeClient(new TNSWebChromeClient());
}
this.webview.src = "~/opentok/opentok.component.html?data=" + JSON.stringify(this.data);
}
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/>
<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BROADCAST_STICKY"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-permission android:name="android.permission.CAPTURE_AUDIO_OUTPUT" />
publisher.cycleVideo().then(({ deviceId }) => {
console.log(deviceId);
}).catch((err) => {
alert('cycleVideo error ' + err.message);
});
}
您是否应该提出解决此问题的想法?还是我错过了为此配置的东西?