【发布时间】:2015-02-06 21:28:24
【问题描述】:
我正在尝试获取官方 Youtube 应用程序上可用的最受欢迎的视频或观看的内容,以显示在我使用 Youtube api v3 的 youtube 应用程序中。
我使用以下代码搜索具有特定关键字的视频..
public List<VideoItem> search(String keywords) {
query.setQ(keywords);
try {
SearchListResponse response = query.execute();
List<SearchResult> results = response.getItems();
List<VideoItem> items = new ArrayList<VideoItem>();
for (SearchResult result : results) {
String videoURL = "http://www.youtube.com/watch?v=" + result.getId().getVideoId();
VideoItem item = new VideoItem(result.getSnippet().getTitle(),
result.getSnippet().getDescription(), result
.getSnippet().getThumbnails().getDefault()
.getUrl(), result.getId().getVideoId(), videoURL);
items.add(item);
}
return items;
} catch (IOException e) {
Log.d("YC", "Could not search: " + e);
return null;
}
}
它运行良好..但我不知道如何让 What to Watch 显示在我的主要活动中..我找到 this 但它只适用于版本 2..有什么想法吗?
【问题讨论】:
标签: android youtube-api android-youtube-api