I would like to display the default thumbnail image of this YouTube URL in an Android app:
<iframe width="560" height="315" src="https://www.youtube.com/embed/FXx_gbdIUKg" frameborder="0" allowfullscreen=""></iframe>
This is my method for doing this:
static String parseThumbnail(String youTubeURL){
org.jsoup.nodes.Document document = Jsoup.parse(youTubeURL);
Elements youtubeElements = document.select("FXx_gbdIUKg");
org.jsoup.nodes.Document iframeDoc = Jsoup.parse(youtubeElements.get(0).data());
Elements iframeElements = iframeDoc.select("iframe");
return iframeElements.attr("http://img.youtube.com/vi/"+youtubeElements+"/default.jpg");
the iframe is inside the "content: encoded" node, so I call this method here.
String itemYouTubeImage = null;
if (XML_TAG_CONTENT_ENCODED.equalsIgnoreCase(tag)) {
String contentEncoded = tagNode.getTextContent();
itemYouTubeImage = parseThumbnail(contentEncoded);
itemImageURL = parseImageFromHTML(contentEncoded);
itemContentEncodedText = parseTextFromHTML(contentEncoded);
How to do it right?
One of the problems is that the compiler tells me that the value parseThumbnail(contentEncoded)assigned itemYouTubeImageis never used
source
share