Note that there are some explanatory texts on larger screens.

plurals
  1. POYoutube Api on android
    text
    copied!<p>I'm want to upload video to YouTube from Android, I use Google API to do it, my code:</p> <pre><code>import com.google.gdata.client.youtube.YouTubeService; import com.google.gdata.data.media.MediaFileSource; import com.google.gdata.data.media.mediarss.MediaCategory; import com.google.gdata.data.media.mediarss.MediaDescription; import com.google.gdata.data.media.mediarss.MediaKeywords; import com.google.gdata.data.media.mediarss.MediaTitle; import com.google.gdata.data.youtube.VideoEntry; import com.google.gdata.data.youtube.YouTubeMediaGroup; import com.google.gdata.data.youtube.YouTubeNamespace; import com.google.gdata.util.AuthenticationException; import com.google.gdata.util.ServiceException; public void uploadVideo() { YouTubeService service = new YouTubeService(clientId,developerKey); try { service.setUserCredentials(username, password); } catch (AuthenticationException ex) { Log.e("AuthenticationError",":"+ex.getMessage()); return; } File videoFile = new File("/sdcard/Ronaldinho.mp4"); if(!videoFile.exists()) { Log.e("FileUploadErr","FileNotFound"); return; } String mimeType = "video/mp4"; String videoTitle = "English Communicaton"; VideoEntry newEntry = new VideoEntry(); YouTubeMediaGroup mg = newEntry.getOrCreateMediaGroup(); mg.addCategory(new MediaCategory(YouTubeNamespace.CATEGORY_SCHEME,"Tech")); mg.setTitle(new MediaTitle()); mg.getTitle().setPlainTextContent(videoTitle); mg.setKeywords(new MediaKeywords()); mg.getKeywords().addKeyword("learning english"); mg.setDescription(new MediaDescription()); mg.getDescription().setPlainTextContent(videoTitle); MediaFileSource ms = new MediaFileSource(videoFile,mimeType); newEntry.setMediaSource(ms); try { service.insert(new URL(urlUpload), newEntry); } catch(ServiceException se) { Log.e("UploadVideo",":" + se.getMessage()); } catch(IOException ioex) { Log.e("IOExceptionVideoUpload",":" + ioex.getMessage()); } } </code></pre> <p>I'm not sure that this code can run on android, because i get a forbidden error. </p> <p>My quesion is why is this code working on Android? Is gdata not compatible with Android?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload