Posted By

bcmoney on 12/06/12


Tagged

browser video player jmf YouTube embedded


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

bcmoney


YouTubePlayer.java


 / Published in: Java
 

URL: http://www.javalobby.org/java/forums/t103917.html

Requires "Guava lib", as well as the main dependencies listed in the above link:

  • gdata-youtube-2.0.jar
  • gdata-core-2.0.jar
  • gdata-media-2.0.jar
  • gdata-client-2.0.jar
  • mail.jar

Then configure your API_KEY and APP configs: https://code.google.com/apis/youtube/dashboard/gwt/index.html#product/

Then you should be able to search YouTube from a Native cross-platform JAVA desktop app; after this, next steps are to:

  1. Test searches and ensure its working well.
  2. Integrate Tidy HTML parsing and generate YouTube tags.
  3. Setup lightweight HTML file to accept video IDs as parameter and render a player: http://jsfiddle.net/bcmoney/yBP4J/
  4. Integrate WebRenderer: http://webrenderer.com/ (or other embedded J2EE broswer)
  5. Test playback of video in Embedded Browser, Mobile support, (see BB demos, etc): http://devblog.blackberry.com/2011/01/communication-api-2/
  6. Integrate with BlogOfBug's JCarousel: http://web.archive.org/web/20070203112659/http://www.blogofbug.com/page3/page3.html
  7. Find inspiration to finish OpenRecommender!!!!!!!
  1. package net.bcmoney;
  2.  
  3. import com.google.gdata.client.youtube.YouTubeService;
  4. import com.google.gdata.data.Person;
  5. import com.google.gdata.data.TextConstruct;
  6. import com.google.gdata.data.youtube.VideoEntry;
  7. import com.google.gdata.data.youtube.VideoFeed;
  8. import com.google.gdata.util.ServiceException;
  9. import java.io.IOException;
  10. import java.net.URL;
  11. import java.util.Iterator;
  12. import java.util.List;
  13. import java.util.logging.Level;
  14. import java.util.logging.Logger;
  15.  
  16. /**
  17.  *
  18.  * @author bcbcope
  19.  */
  20. public class YouTubePlayer {
  21.  
  22. public YouTubePlayer() {
  23.  
  24. }
  25.  
  26. private static void printVideoFeed(YouTubeService service, String feedUrl) throws IOException, ServiceException {
  27. VideoFeed videoFeed = service.getFeed(new URL(feedUrl), VideoFeed.class);
  28. List<VideoEntry> allVideos = videoFeed.getEntries();
  29. Iterator<VideoEntry> itAllVideos = allVideos.iterator();
  30. while (itAllVideos.hasNext()){
  31. VideoEntry oneVideo = itAllVideos.next();
  32. TextConstruct oneVideoTitle = oneVideo.getTitle();
  33. String oneVideoTitleText = oneVideoTitle.getPlainText();
  34. //Print titles of all videos:
  35. System.out.print(oneVideoTitleText);
  36. List<Person> allAuthors = oneVideo.getAuthors();
  37. Iterator<Person> itAllAuthors = allAuthors.iterator();
  38. while (itAllAuthors.hasNext()){
  39. Person oneAuthor = itAllAuthors.next();
  40. //Print authors of current title:
  41. System.out.print(" (by " + oneAuthor.getName() +")\n");
  42. }
  43. }
  44. }
  45.  
  46. public static void main(String[] args) {
  47. try {
  48. YouTubeService myService = new YouTubeService("mycompany-myapp-1");
  49. String myFeed = "http://gdata.youtube.com/feeds/videos?start-index=1&max-results=25&vq=lizards&oi=spell";
  50. printVideoFeed(myService, myFeed);
  51. } catch (IOException ex) {
  52. Logger.getLogger(YouTubePlayer.class.getName()).log(Level.SEVERE, null, ex);
  53. } catch (ServiceException ex) {
  54. Logger.getLogger(YouTubePlayer.class.getName()).log(Level.SEVERE, null, ex);
  55. }
  56. }
  57. }

Report this snippet  

You need to login to post a comment.