user6683711
user6683711

Reputation:

Audio not working

var audio = new Audio("https://onedrive.live.com/embed?cid=8E89450E6091B685&resid=8E89450E6091B685%21725&authkey=AMbCpgb-EbUhsVs");
audio.play;

This code does not play any sound, it only returns:

=> [Function: play]

Upvotes: 0

Views: 1050

Answers (1)

Nick Christiny
Nick Christiny

Reputation: 102

=> [Function: play] 

looks to be indicating the intended usage and that it expects a form like the one given by Chrome 54:

function play() { [native code] }

audio.play() returns a Promise. Currently in console, [[PromiseStatus]]:"rejected" due to DOMException: The element has no supported sources.

I suggest using a Promise to play the audio. Here is an example: https://googlechrome.github.io/samples/play-return-promise/ and the post explaining the example: https://developers.google.com/web/updates/2016/03/play-returns-promise

There is also this similar question: How can i create a promise for the end of playing sound?

Upvotes: 2

Related Questions