JavaScript获得Audio.setSinkId的权限

问题描述 投票:4回答:1
var audio = new Audio();
audio.setSinkId("communications");

我将收到此错误:

DOMException: No permission to use requested device

因此,为了获得许可,我试图这样做:

navigator.webkitGetUserMedia({
    audio: true
}, (stream) => {
    console.log("stream: ", stream);
}, (error) => {
    console.log("error: ", error);
});

但是现在我明白了:

error:
NavigatorUserMediaError {name: "InvalidStateError", message: "", constraintName: ""}

我不知道,是否

- 'audio' is not available (but actually it should)
- I need a secure connection (but how do I get this at a chrome app?)

我正在尝试在chrome应用程序的音频元素中更改sinkId。代码:var audio = new Audio(); audio.setSinkId(“通讯”);我将收到此错误:DOMException:没有使用权限...

javascript google-chrome audio google-chrome-app
1个回答
0
投票

根据规格,应该有一个Permission.request()方法,该方法应该接受PermissionDescriptor

© www.soinside.com 2019 - 2024. All rights reserved.