uniapp app 获取麦克风权限
时间: 2023-09-14 11:15:01 浏览: 1326
在uniapp中,可以通过添加相应的代码来获取麦克风权限。在需要获取麦克风权限的页面,可以使用以下代码弹出是否开启麦克风权限的提醒:
```javascript
plus.android.requestPermissions(['android.permission.RECORD_AUDIO'], function(e) {
if (e.deniedAlways.length > 0) {
// 权限被永久拒绝
// 弹出提示框解释为何需要麦克风权限,引导用户打开设置页面开启
console.log('Always Denied!!! ' + e.deniedAlways.toString());
}
if (e.deniedPresent.length > 0) {
// 权限被临时拒绝
// 弹出提示框解释为何需要麦克风权限,可再次调用plus.android.requestPermissions申请权限
console.log('Present Denied!!! ' + e.deniedPresent.toString());
}
if (e.granted.length > 0) {
// 权限被允许
// 调用依赖获取麦克风权限的代码
console.log('Granted!!! ' + e.granted.toString());
}
}, function(e) {
console.log('Request Permissions error:' + JSON.stringify(e));
});
```
通过以上代码,可以实现获取麦克风权限的功能,并根据用户的操作结果进行相应的处理。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [permission.js](https://download.csdn.net/download/weixin_41970780/85670970)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *2* [uni-app 录音权限安装时没提醒开启的问题](https://blog.csdn.net/qq_35827660/article/details/118765471)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *3* [uni_app授权登录及授权麦克风防止用户点击拒绝按钮,权限无法再次被挂起。](https://blog.csdn.net/m0_66523895/article/details/125662064)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"]
[ .reference_list ]
相关推荐
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)