Geckoview获得麦克风许可 [英] Geckoview get microphone permission

查看:193
本文介绍了Geckoview获得麦克风许可的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从GeckoView元素内的网站使用音频录制功能. 因此,我在AndroidManifest.xml中设置了权限:

I am trying to use the audio recording feature from a website inside a GeckoView element. Therefore I set the permission inside AndroidManifest.xml:

<uses-permission android:name="android.permission.RECORD_AUDIO" />

当我现在尝试在网站上录制音频时,HTML PopUp(属于网站的一部分,而不是浏览器的功能)告诉我我需要授予许可.我无能为力-只是没有按钮的音符.

When I now try to record the audio on the website, an HTML PopUp (which is part of the website, not a feature of the browser) tells me that I need to give permission. I can't do anything else - it's just a note without buttons.

另一方面:当我使用常规的Firefox浏览器时,浏览器会问我是否要在显示此HTML PopUp的同时向该网站的麦克风授予权限.

On the other hand: when I use the regular Firefox browser, the browser asks me if I want to grant permission to my mic for this website while this HTML PopUp is shown.

我没有收到GeckoView的询问,因此需要找到一种方法来授予在GeckoView内部使用该网站的麦克风的权限. 我是否需要在GeckoView内授予权限?我查阅了有关GeckoView权限的文档,但无法使其正常工作(可能是由于我的基本编码知识).

I don't get asked that by GeckoView and therefore need to find a way to grant permission to use the mic for this website inside GeckoView. Do I need to give permission inside GeckoView? I looked up the documentation on permissions of GeckoView but could not get it to work (probably because of my basic coding knowledge).

非常感谢您的帮助!

非常感谢!

推荐答案

GeckoView本身不显示任何权限对话框.但是,它为此提供了一个委托,您可以自己实现:GeckoSession.setPromptDelegate().

GeckoView itself does not show any permission dialogs. However it provides a delegate for it that you can implement yourself: GeckoSession.setPromptDelegate().

您基本上必须做两件事:

You basically have to do two things:

  1. 如果需要,可以通过实现GeckoSession.PermissionDelegate.onAndroidPermissionsRequest()向Android系统请求权限.
  2. 通过实现GeckoSession.PermissionDelegate.onContentPermissionRequest()来处理来自网站的内容许可请求,这取决于在提供的callback对象上调用grant()reject().
  1. Request a permission from the Android system if needed by implementing GeckoSession.PermissionDelegate.onAndroidPermissionsRequest().
  2. Process the content permission request from the website by implementing GeckoSession.PermissionDelegate.onContentPermissionRequest() - which comes down to calling grant() or reject() on the provided callback object.

Mozilla的Android组件项目为该功能和许多其他浏览器功能"提供了实现在GeckoView顶部-如果您不想使用自定义实现.像" Firefox预览"之类的浏览器都使用此项目中的实现.

The Mozilla's Android Components project provides implementations for this and many other "browser features" on top of GeckoView - if you do not want to have a custom implementation. Browsers like "Firefox Preview" use the implementations from this project.

这篇关于Geckoview获得麦克风许可的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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