Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Uploading file with JavaScript Youtube API - MediaUploader is not defined

I'm working on a web app, trying to enable sharing a video on Youtube, essentially adding an "Upload to youtube" button. I'm trying to use the Youtube Data API for JavaScript, following this example https://developers.google.com/youtube/v3/code_samples/javascript#upload_video.

My code is the same as in the example. All was going well until I got an error "MediaUploader is not defined" from this line of code:

var uploader = new MediaUploader({

The MediaUploader class doesn't seem to be defined anywhere in the example code.

I've searched far and wide through Google API docs and JS ref, but the only mention of a MediaUploader class I found is in the context of WordPress, PHP or Python.

Please help - what is MediaUploader in the context of JavaScript/Google API and where can I find documentation on it?

like image 589
dmk12 Avatar asked Mar 02 '15 20:03

dmk12


1 Answers

Ok, got back to this task & finally found the answer. The MediaUploader class is defined in https://github.com/youtube/api-samples/blob/master/javascript/cors_upload.js.

Dear Google/Youtube docs maintenance people, if you ever read this please add this code sample to the official docs on resumable upload using JavaScript! It will save a world of pain.

like image 158
dmk12 Avatar answered Sep 21 '22 10:09

dmk12