Issue
I am building an app that uses the YouTube iFrame Api.
Everything works fine when there is Internet connection (the onYouTubeIframeAPIReady function gets called correctly). But when I try to load the .html that contains the stuff mentioned in Docs#GettingStarted, onYouTubeIframeAPIReady never gets called (which I think that is correct), but I do not know which function (nor if there is one) is called notifying that some error occurred.
All in all, which function is called when some error prevents onYouTubeIframeAPIReady from being called? Is there one?
I have just tried to implement the "onError" function, but it also seems to not being called in that situation =/
Solution
I have just realized that I was heading the wrong path. This is no YouTube's fault to take at all.
The problem itself is that the script fails to load, so that's what we need to track. We can do it by registering an onerror callback:
// ...
var tag = document.createElement('script');
tag.id = 'iframe-demo';
tag.src = 'https://www.youtube.com/iframe_api';
tag.onerror = function() {
// do what you need here. The script failed to load
}
// ...
Answered By - Augusto Carmo
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.