我正在尝试获取最受欢迎的视频,或者在使用Youtube api v3的youtube应用程序中显示在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;
}
}它工作的很完美..但是我不知道如何在我的主要活动中显示要观看的内容。我找到了this,但它只在版本2中起作用。有什么想法吗?
发布于 2015-05-26 03:22:42
使用YouTube接口V3的开发者接口密钥,使用以下内容来检索YouTube接口V3中的热门视频:
https://www.googleapis.com/youtube/v3/videos?chart=mostPopular&key={YOUR_API_KEY}&part=snippet&maxResults=4https://stackoverflow.com/questions/28375112
复制相似问题