Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

YouTube API with async! plugin #36

Open
mhrisse opened this issue Sep 14, 2013 · 2 comments
Open

YouTube API with async! plugin #36

mhrisse opened this issue Sep 14, 2013 · 2 comments

Comments

@mhrisse
Copy link

mhrisse commented Sep 14, 2013

Hi!

I have a little trouble loading the YouTube Iframe API using the !async plugin, any help appreciated! (Hope it's ok to highight this here).

The maps example works, so I am currently assuming the basic setup must be ok:

define('something', [
'async!http://maps.google.com/maps/api/js?sensor=false'
], function () { console.log('loaded..'); } 
);

// doesn't work
define('something', [
'async!https://www.youtube.com/iframe_api!callback'
], function () { console.log('loaded..'); } 
);

// doesn't work
define('something', [
'async!https://www.youtube.com/iframe_api!onYouTubeIframeAPIready'
], function () { console.log('loaded..'); } 
);

// doesn't work
define('something', [
'async!https://www.youtube.com/iframe_api'
], function () { console.log('loaded..'); } 
);

They all get me the Uncaught Error: Load timeout for modules: async!https://www.youtube.com/iframe_api!onload_unnormalized2,async!https://www.youtube.com/iframe_api!onload
http://requirejs.org/docs/errors.html#timeout or similar (depeding on setting after the second !)

which probably means the callback function is never called. If I defined the callback function myself it works.. but still getting the timeout error.

window.onYouTubeIframeAPIready = function () {
console.log('youtube api usual callback');
}
@mhrisse
Copy link
Author

mhrisse commented Oct 3, 2013

Hacking the plugin like this does the trick:

                // var id = uid();
                var id = 'onYouTubeIframeAPIReady';

I would like to commit a patch, but I am not sure how to signal the plugin that it should not use the global callback generated uid(), but a set global variable.

What's the desired syntax in the require call for this?
Maybe a colon is a valid suggestion to split parameters? I guess passing in a json object after the second ! is out / would look a little techy?

require([
'async!//www.youtube.com/iframe_api!callback:onYouTubeIframeAPIReady'
], function () { .. });

Any suggestions?

@mhrisse
Copy link
Author

mhrisse commented Oct 5, 2013

I have commited a pull request solving the issue as outlined above: #39

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant