Committed by
GitHub
Fix getting microphone permission for HarmonyOS VAD+ASR example (#1582)
正在显示
1 个修改的文件
包含
7 行增加
和
1 行删除
| @@ -46,8 +46,14 @@ struct Index { | @@ -46,8 +46,14 @@ struct Index { | ||
| 46 | const permissions: Permissions[] = ["ohos.permission.MICROPHONE"]; | 46 | const permissions: Permissions[] = ["ohos.permission.MICROPHONE"]; |
| 47 | let allowed: boolean = await allAllowed(permissions); | 47 | let allowed: boolean = await allAllowed(permissions); |
| 48 | if (!allowed) { | 48 | if (!allowed) { |
| 49 | - requestPermissions(permissions); | ||
| 50 | console.log("request to access the microphone"); | 49 | console.log("request to access the microphone"); |
| 50 | + const status: boolean = await requestPermissions(permissions); | ||
| 51 | + | ||
| 52 | + if (!status) { | ||
| 53 | + console.error('access to microphone is denied') | ||
| 54 | + this.resultForMic = "Failed to get microphone permission. Please retry"; | ||
| 55 | + return; | ||
| 56 | + } | ||
| 51 | 57 | ||
| 52 | allowed = await allAllowed(permissions); | 58 | allowed = await allAllowed(permissions); |
| 53 | if (!allowed) { | 59 | if (!allowed) { |
-
请 注册 或 登录 后发表评论