作者:love28119_529_700 | 来源:互联网 | 2023-02-03 19:16
我正在开发具有视频聊天功能的移动应用.我为webrtc找到了一个不错的Javascript库,它似乎加载得很好,QWebView
但我需要授予它访问摄像头和麦克风的权限,我无法弄清楚如何做到这一点.可能吗?QWebEngineView
有一个方便的信号和插槽,但它不支持移动.
所描述的清单权限不工作在这里.
相应的Qt bug:无法通过QML WebView访问摄像头和麦克风
有任何想法吗?
1> Hubi..:
Qt在5.10版本中实现了Android的权限模型.
见这里:http://doc.qt.io/qt-5/qtandroid.html.
您必须使用的功能是:
的checkPermission
requestPermissions
requestPermissionsSync
如果要访问摄像头和麦克风,则必须在使用前请求权限.例:
QStringList perms;
perms <<"android.permission.CAMERA" <<"android.permission.RECORD_AUDIO";
QtAndroid::checkPermissions(perms, [](const PermissionResultMap& resMap) {
foreach(const QString &key, resMap.keys()) {
qDebug() <<"Result of permission" <
2> GensaGames..:
清单权限不适用于Android 22>.因此,在您的情况下,您需要访问运行时权限.在Java中执行此操作.
if (ContextCompat.checkSelfPermission(thisActivity,
Manifest.permission.READ_CONTACTS)
!= PackageManager.PERMISSION_GRANTED) {
// Should we show an explanation?
if (ActivityCompat.shouldShowRequestPermissionRationale(thisActivity,
Manifest.permission.READ_CONTACTS)) {
// Show an explanation to the user *asynchronously* -- don't block
// this thread waiting for the user's response! After the user
// sees the explanation, try again to request the permission.
} else {
// No explanation needed, we can request the permission.
ActivityCompat.requestPermissions(thisActivity,
arrayOf(Manifest.permission.READ_CONTACTS),
MY_PERMISSIONS_REQUEST_READ_CONTACTS)
// MY_PERMISSIONS_REQUEST_READ_CONTACTS is an
// app-defined int constant. The callback method gets the
// result of the request.
}
}
从官方文件中看到.但在你的情况下,我认为你需要通过NDK级别来调用相同的行为.它也在这里描述.