I've the layout for a YouTube video. I would like to set the video's Thumbnail and Title. (I succeeded to set the thumbnail but not the title)
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="1.0">
<com.google.android.youtube.player.YouTubeThumbnailView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="6dp"
android:layout_marginTop="10dp"
android:id="@+id/youtubeThumbnailView"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="YouTube Video"
android:textSize="20sp"
android:layout_marginLeft="4dp"
android:layout_marginTop="10dp"
android:layout_gravity="center"
android:id="@+id/textViewTitle"/>
</LinearLayout>
I set the Thumbnail here:
YouTubeThumbnailView youTubeThumbnailView = (YouTubeThumbnailView) newChild.findViewById(R.id.youtubeThumbnailView);
youTubeThumbnailView.initialize(YouTubePlayer.DEVELOPER_KEY, new YouTubeThumbnailView.OnInitializedListener() {
@Override
public void onInitializationSuccess(YouTubeThumbnailView youTubeThumbnailView, final YouTubeThumbnailLoader youTubeThumbnailLoader) {
youTubeThumbnailLoader.setVideo("FM7MFYoylVs");
youTubeThumbnailLoader.setOnThumbnailLoadedListener(new YouTubeThumbnailLoader.OnThumbnailLoadedListener() {
@Override
public void onThumbnailLoaded(YouTubeThumbnailView youTubeThumbnailView, String s) {
youTubeThumbnailLoader.release();
}
@Override
public void onThumbnailError(YouTubeThumbnailView youTubeThumbnailView, YouTubeThumbnailLoader.ErrorReason errorReason) {
}
});
}
@Override
public void onInitializationFailure(YouTubeThumbnailView youTubeThumbnailView, YouTubeInitializationResult youTubeInitializationResult) {
}
});
How do I get the title from the video?
I saw a solution here: Get title of YouTube video
but I'm not sure if this is the correct way. I guess that YouTube API lets us get the title in an easier way such as: youTubeThumbnailView.getText() for example.