在下一个js中出现新订单时,在浏览器中播放mp3时面临问题

Facing issue play mp3 in browser when new order comming time in next js

提问人:Keval Rana 提问时间:11/17/2023 更新时间:11/17/2023 访问量:19

问:

现在我需要在没有用户反应的情况下在浏览器中播放 mp3。

当前代码:

const audio = new Audio(newOrderRing);
audio.play().catch((error) =\> {
// eslint-disable-next-line no-console
console.error('Error playing audio:', error);
});

在Safari浏览器中面临自动播放权限问题。

错误:

NotAllowedError:在当前上下文中,用户代理或平台不允许该请求,可能是因为用户拒绝了权限。

NotAllowedError:play() 失败,因为用户没有先与文档交互。

在 safari 中,我需要手动添加权限才能在站点中播放 mp3。 网址: https://memrise.zendesk.com/hc/en-us/articles/360015889117-How-can-I-allow-audio-to-auto-play-on-Safari-

JavaScript reactjs next.js next.js13

评论

0赞 Community 11/17/2023
请澄清您的具体问题或提供其他详细信息以准确说明您的需求。正如目前所写的那样,很难确切地说出你在问什么。

答: 暂无答案