Fix getting microphone permission for HarmonyOS VAD+ASR example (#1582)

This commit is contained in:
Fangjun Kuang
2024-11-30 16:24:22 +08:00
committed by GitHub
parent c9d3b6cd8c
commit a3d6e1acc7

View File

@@ -46,8 +46,14 @@ struct Index {
const permissions: Permissions[] = ["ohos.permission.MICROPHONE"];
let allowed: boolean = await allAllowed(permissions);
if (!allowed) {
requestPermissions(permissions);
console.log("request to access the microphone");
const status: boolean = await requestPermissions(permissions);
if (!status) {
console.error('access to microphone is denied')
this.resultForMic = "Failed to get microphone permission. Please retry";
return;
}
allowed = await allAllowed(permissions);
if (!allowed) {