Emotional Code|

Nolca

园龄:6年9个月粉丝:12关注:9

Safari Webkit, NotAllowedError: The request is not allowed

使用tauri v2,跑前后端项目学习时,遇到这条报错:

Unhandled Promise Rejection: NotAllowedError: The request is not allowed by the user agent or the platform in the current context, possibly because the user denied permission.

测试代码

console.log(navigator.userAgent);
navigator.permissions.query({name:'camera'}).then(per=>console.log(per.state));
navigator.mediaDevices.getUserMedia({audio: true}).then(stream => console.log(stream)).catch(err => console.error(err));
navigator.mediaDevices.getUserMedia({video: true}).then(stream => console.log(stream)).catch(err => console.error(err));

结果

[Log] Mozilla/5.0 (X11; Ubuntu; Linux x86_64) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Safari/605.1.15
[Log] prompt
[Error] NotAllowedError: The request is not allowed by the user agent or the platform in the current context, possibly because the user denied permission.
Console Evaluation (Console Evaluation 26:5:115)
[Error] OverconstrainedError {message: "Invalid constraint", constraint: "", name: "OverconstrainedError"}
Console Evaluation (Console Evaluation 37:3:115)

虽然是prompt,但没有弹窗申请权限,所以导致NotAllowedError

解决

tauri还不成熟,换用electron吧
https://github.com/tauri-apps/wry/issues/85

本文作者:Nolca

本文链接:https://www.cnblogs.com/nolca/p/18462652

版权声明:本作品采用 收益分享revenue sharing 许可协议进行许可。

posted @   Nolca  阅读(236)  评论(0编辑  收藏  举报
历史上的今天:
2022-10-13 码农也要注意身体健康 q(≧▽≦q)
点击右上角即可分享
微信分享提示
评论
收藏
关注
推荐
深色
回顶
收起
  1. 1 ⏩intro 山姆精
  2. 2 🎸吉他 马叉
  3. 3 ☁升调 山姆精
  4. 4 🐦Flutter Virtual Riot/Madi
  5. 5 🎶纯律 山姆精
  6. 6 👻yeah~Color Bass! VR
⏩intro - 山姆精
00:00 / 00:00
An audio error has occurred, player will skip forward in 2 seconds.