【发布时间】:2019-04-03 16:46:12
【问题描述】:
我想在倒计时结束后播放声音。 通常我会使用这种和平的代码来做到这一点
var audio = new Audio('path to file.mp3');
audio.play();
但是我得到以下错误Unhandled Promise Rejection: NotAllowedError: The request is not allowed by the user agent or the platform in the current context,可能是因为用户拒绝了权限。
事情是......谷歌它自己正在使用 HTML5 音频标签来做这件事
如果您在谷歌搜索字段中输入countdown timer,它应该会显示在倒计时结束后播放声音的小部件。
如果你们不知道我在说什么,这就是 Google 计时器的样子:)
【问题讨论】: