Skip to content

Instantly share code, notes, and snippets.

@DHuckaby
Created May 19, 2012 17:04
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DHuckaby/e741f188cdce6ac00d75 to your computer and use it in GitHub Desktop.
Save DHuckaby/e741f188cdce6ac00d75 to your computer and use it in GitHub Desktop.
SimpleYouTubeHelper.java
public class SimpleYouTubeHelper {
public static String getImageUrlQuietly(String youtubeUrl) {
try {
if (youtubeUrl != null) {
return String.format("http://img.youtube.com/vi/%s/0.jpg", Uri.parse(youtubeUrl).getQueryParameter("v"));
}
} catch (UnsupportedOperationException e) {
e.printStackTrace();
}
return null;
}
public static String getTitleQuietly(String youtubeUrl) {
try {
if (youtubeUrl != null) {
URL embededURL = new URL("http://www.youtube.com/oembed?url=" + youtubeUrl + "&format=json");
return new JSONObject(IOUtils.toString(embededURL)).getString("title");
}
} catch (JSONException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
}
@soyaleye
Copy link

soyaleye commented Nov 3, 2017

Simple adroid app

Hello, I am struggling with an assignment in my android development class which requires me to build a simple android app that will connect two devices via Bluetooth, then share information about what YouTube video one device is playing on its browser . This will be implemented in such a way that the discoverable Bluetooth name is always updated as the name of the current YouTube video. Lastly, the user on the other device should be able to click on the YouTube video information and have a browser launch to play the video.

A simple GUI where all of these can be implemented would be appreciated.

Please help me with this and I will be willing to make a donation to your YouTube channel.

You can contact me on soyaleye@gmail.com.

Thanks.

@GurpreetSinghMetho
Copy link

GurpreetSinghMetho commented Apr 21, 2018

Hello can you please give me IOUtils.toString(embededURL) this method
just mail me on guris.1068@gmail.com

Thanks in advance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment