Developers : How to attach video in your website using java?
UPDATED: 16 March 2012
Tags:
How to
,
J2EE
,
javaQuery API
After long time I'm back to javaQuery article. Today m gonna show you how google+, Facebook, Twitter embed videos in there post, Tweet, etc... I was working on this code. This code will cover all video website like Youtube, vimeo, etc... that contains video information in proper formation. Check out the below code to demonstrate the URL. This library is present in latest javaQuery API. Some website may not be support by this API.
Once you done with the code. You can change the properties of video attachment for your page. Change the video CSS, width, height.
Check out the http://www.javaquery.com/p/javaquery-api.html for download.
/* * javaQueryAPI 7.0 or less */ import javaQuery.j2ee.EmbedVideo; public class Video { public static void main(String[] args) { String WebVideo = ""; EmbedVideo em = new EmbedVideo(); boolean flag = em.EmbedVideo("http://www.youtube.com/watch?v=0N9JxHEoYd4"); //flag will return true if website/link contains video details in proper format. if (flag) { System.out.println(EmbedVideo.provider_name); System.out.println(EmbedVideo.provider_url); System.out.println(EmbedVideo.author_name); System.out.println(EmbedVideo.author_url); System.out.println(EmbedVideo.title); System.out.println(EmbedVideo.description); System.out.println(EmbedVideo.html); System.out.println(EmbedVideo.width); System.out.println(EmbedVideo.height); System.out.println(EmbedVideo.thumbnail_url); System.out.println(EmbedVideo.video_url); System.out.println(EmbedVideo.xml_type); WebVideo = "Author:"+EmbedVideo.author_name; //Modify the Data as per your requirement like place the video in iframe } } }
/* * javaQueryAPI 8.0 or above * This code requires additional JSON library. You must include JSON lib to work this API. Its available in javaQueryAPI 8.0/lib folder on sourceforge.net */ import javaQuery.importClass.javaQueryBundle; import javaQuery.j2ee.embedvideo; public class Demo { public static void main(String[] args) { embedvideo em = javaQueryBundle.create_embedvideo(); em.linkTo("http://www.youtube.com/watch?v=SmM0653YvXU"); System.out.println(em.title); System.out.println(em.video_url); System.out.println(em.description); System.out.println(em.width); System.out.println(em.height); System.out.println(em.thumbnail_url); System.out.println(em.author_name); System.out.println(em.author_url); System.out.println(em.html); System.out.println(em.provider_name); System.out.println(em.provider_url); } } /* * output * Pitbull - Rain Over Me ft. Marc Anthony * http://www.youtube.com/watch?v=SmM0653YvXU * Not Available * 480 * 270 * http://i4.ytimg.com/vi/SmM0653YvXU/hqdefault.jpg * PitbullVEVO * http://www.youtube.com/user/PitbullVEVO * <iframe allowfullscreen="" frameborder="0" height="270" src="http://www.youtube.com/embed/SmM0653YvXU?feature=oembed" width="480"></iframe> * YouTube * http://www.youtube.com/ */
Once you done with the code. You can change the properties of video attachment for your page. Change the video CSS, width, height.
Check out the http://www.javaquery.com/p/javaquery-api.html for download.
Tags:
How to
,
J2EE
,
javaQuery API
0 comments :