如何以编程方式删除授予我的 web 应用程序的麦克风权限? [英] How to programatically remove microphone permission given to my webapp?

查看:62
本文介绍了如何以编程方式删除授予我的 web 应用程序的麦克风权限?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我使用 navigator.mediaDevices.getUserMedia({ audio: true }) 获得麦克风权限并使用媒体流完成我想要的所有操作后,如何删除麦克风权限并从选项卡和工具栏?

After I obtained microphone permission with navigator.mediaDevices.getUserMedia({ audio: true }) and done everything I want with media stream how can I remove microphone permission and remove this annoying icon from tab and toolbar?

在检查 LocalMediaStream 对象后,我在原型中发现了 stop() 函数并且它起作用了!

After inspecting LocalMediaStream object I've found stop() function in prototype and it worked!

推荐答案

我建议查看 权限api.

您应该能够撤销许可,类似这样:

You should be able to revoke the permission, something like this:

const microphone = navigator.permissions.query({ name: 'microphone' })
navigator.permissions.revoke(microphone)

我们可以直接在 permissions.query 中使用 microphone 因为它是一个 有效名称.

We can use microphone directly in permissions.query because it is a valid name.

这篇关于如何以编程方式删除授予我的 web 应用程序的麦克风权限?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆