I need to integrate YouTube API into my GWT web application. I need to make YouTube API calls such as the following:
- UPLOAD: https://developers.google.com/youtube/2.0/developers_guide_protocol_browser_based_uploading
- CHECK STATUS: https://developers.google.com/youtube/2.0/developers_guide_protocol_checking_video_status
- SET DEVELOPER TAGS: https://developers.google.com/youtube/2.0/developers_guide_protocol_uploading_videos#Assigning_Developer_Tags
In order to circumvent browser’s same origin restrictions, the calls have to be CORS calls.
How can I make these YouTube API calls from my GWT web application? A small code sample would be greatly appreciated.
Note that I have tried using YouTube Direct Lite, but it seems it doesn’t allow setting developer tags, which is crucial for me.
YouTube has provided a sample showing how YouTube API CORS calls should be made:
You can integrate the JavaScript from the sample into your GWT app using GWT’s JavaScript Native Interface (JSNI):
Note that the sample JavaScript uses
XMLHttpRequestwhich is not supported by some browser versions:XMLHttpRequestsupport matrix