var audio = new Audio("https://onedrive.live.com/embed?cid=8E89450E6091B685&resid=8E89450E6091B685%21725&authkey=AMbCpgb-EbUhsVs");
audio.play;
此代码不播放任何声音,只返回:
=> [Function: play]
答案 0 :(得分:2)
=> [Function: play]
表示预期用途,并且它需要一个类似Chrome 54给出的表单:
function play() { [native code] }
audio.play()
返回一个Promise。由于[[PromiseStatus]]:"rejected"
,目前在控制台中DOMException: The element has no supported sources
。
我建议使用Promise来播放音频。以下是一个示例:https://googlechrome.github.io/samples/play-return-promise/ 以及解释示例的帖子:https://developers.google.com/web/updates/2016/03/play-returns-promise
还有类似的问题:How can i create a promise for the end of playing sound?