我认为这可以使用HTML5音频完成,并带有指向外部音频文件的链接,但有没有办法不使用任何文件并播放声音? (类似于系统警报声或音频铃声,如命令行中的\a
)
我认为通知部分应该很简单。我们可以像往常一样发出通知。
详细信息是:对于您不是所有者的任何网站,假设网页继续显示一些数据,从0到6000的数字。现在,如果您使用想要添加书签,以便每当号码(显示为value: 5200
)大于5000,然后发出声音并发出通知,而不使用外部音频文件,这是可能的,怎么办?
答案 0 :(得分:2)
无法从网页触发系统声音。
但您可以通过Data-URI协议嵌入一个小样本文件,并将其设置为音频元素的src
。
只需将音频文件本身编码为Base-64,并使用正确的mime-type(或使用done for you)预先添加Data-URI标头。
示例:强>
document.querySelector("audio").src = "data:audio/mpeg;base64,//uUZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAWGluZwAAAA8AAAALAAAHyAAPDw8PDw8PDw8eHh4eHh4eHh45OTk5OTk5OTlnZ2dnZ2dnZ2eNjY2NjY2NjY2zs7Ozs7Ozs7PCwsLCwsLCwsLS0tLS0tLS0tLh4eHh4eHh4eHw8PDw8PDw8PD///////////8AAAA8TEFNRTMuOThyBK8AAAAAAAAAADQgJAXAjQABzAAAB8jbBDi/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA//sUZAAP8AAAaQAAAAgAAA0gAAABAAAB/gAAACAAADSAAAAEAYFAwFAoHA4GAAAAAA9CereO6lvfzP5Mp+Zn4BQKBRuXVKoy4nHHMr1pN1NqKDT8MyUpOUZWTuGeuzm5//sUZB4P8AAAf4AAAAgAAA0gAAABAAAB/h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