Closed hwde closed 6 years ago
Further investigations: Safari requires "click to play", this Error is caused by autoplay. The following article explains how to handle it: http://2ality.com/2016/04/unhandled-rejections.html.
By adding a button with an onclick=... below the container I was able to start the video inside an onclick-Handler ... but player.startAd() still raises above handler. I had to poke behind the private with: player.private.player.video.play();
Maybe the eventhandler and an auto-click-to-play-button could be integrated somehow?
I don't want to add a button in this library as it leaves the user interface entirely up to the user. However, it should be possible to modify the code so that player.private.player.video.play()
is called synchronously from player.startAd()
, which should allow the video to play as long as player.startAd()
is called synchronously within a click handler.
However, just from looking at the code, I can't see where the async-ness would be sneaking in. Are you sure you were calling player.startAd()
synchronously and not in a callback? For example:
element.onclick = () => {
player.load('tag.xml').then(() => {
player.startAd(); // won't work because this is an async callback.
});
};
If you could post a jsfiddle that demonstrates your issue, I'd be happy to check it out!
The Example doesn't play in Safari 11 on Mac, it print the following exception, any idea?