我有一个应用程序,可以打开我的网站的网络视图。该网站打开后置摄像头拍照。我可以完成直到完成,但是默认情况下,所选的相机不是首选。在我的三星S10中,打开的相机是广角镜头,非常不方便。
我如何选择最好的相机?有人知道解决方法吗?
在台式机或移动浏览器中,执行navigator.mediaDevices.enumerateDevices()
时会显示标签,但在Web视图中为空。
这是我的webrtc函数:
await this.stopTracksCamera();
let idealDevideId = undefined;
await navigator.mediaDevices.getUserMedia({ video: true }).then(async stream => {
this.tempStream = stream;
});
idealDevideId = await this.scanDevices();
await this.stopTracksCamera();
await navigator.mediaDevices.getUserMedia(constraints).then(stream => {
this.videoDom.srcObject = stream;
...
以及我的应用的网络视图设置:
WebView web = (WebView) findViewById(R.id.silt_web);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
web.setWebContentsDebuggingEnabled(true);
}
WebSettings webSettings = web.getSettings();
webSettings.setJavaScriptEnabled(true);
webSettings.setDomStorageEnabled(true);
webSettings.setJavaScriptCanOpenWindowsAutomatically(true);
webSettings.setAllowFileAccessFromFileURLs(true);
webSettings.setAllowUniversalAccessFromFileURLs(true);
webSettings.setPluginState(WebSettings.PluginState.ON);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
webSettings.setMediaPlaybackRequiresUserGesture(false);
}
web.setWebViewClient(new WebViewClient());
web.setWebChromeClient(new WebChromeClient() {
@Override
public void onPermissionRequest(final PermissionRequest request) {
Log.d(TAG, "onPermissionRequest");
MainActivity.this.runOnUiThread(new Runnable() {
@TargetApi(Build.VERSION_CODES.M)
@Override
public void run() {
Log.d(TAG, request.getOrigin().toString());
/*if(request.getOrigin().toString().equals("file:///")) {*/
Log.d(TAG, "GRANTED");
request.grant(request.getResources());
/*} else {
Log.d(TAG, "DENIED");
request.deny();
}*/
}
});
}
...