我已经制作了YouTube视频的布局。我想设置视频的缩略图和标题。 (我成功地设置缩略图而不是标题)如何通过YouTube API获取YouTube视频的标题
<?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>
我设置缩略图浏览:
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) {
}
});
我如何从视频标题?
我看到这里的解决方案:Get title of YouTube video
,但我不知道这是正确的方式。我猜YouTube API可以让我们以更简单的方式获得标题,例如:youTubeThumbnailView.getText()。
是的,这是我写的,我发现的解决方案。奇怪的是,我找不到来自YouTube API的东西 –
让我看看json –
哪个json?我不知道我知道如何得到它 –