【发布时间】:2016-05-29 00:58:59
【问题描述】:
我的应用程序开发停滞不前:我正在尝试在 youtube 搜索列表中获取播放列表 ID(我正在搜索播放列表)。我正在查看 youtube api 站点和带有播放列表 ID 的测试站点。在我的应用程序上,我也这样做,但我没有得到 ID,或者我没有在迭代代码的“项目”上看到它。
我知道当前正在搜索视频 ID,但它不正确。到目前为止我已经尝试过:
item.id
item.getId().getPlaylistId()
item.getId().playlistId
也完全在项目内。
我给你我的异步任务代码:
SearchListResponse searchResponse;
try {
YouTube.Search.List search = mYouTubeDataApi.search().list("id,snippet");
search.setKey(ApiKey.YOUTUBE_API_KEY);
search.setQ(mTitle);
search.setType("playlist");
search.setFields("items(id/kind,id/videoId,snippet/title,snippet/thumbnails/default/url)");
search.setMaxResults(YOUTUBE_PLAYLIST_MAX_RESULTS);
searchResponse = search.execute();
} catch (IOException e) {
e.printStackTrace();
return null;
}
if (searchResponse == null) {
Log.e(TAG, "Failed to get playlist");
return null;
}
ArrayList videoIds = new ArrayList();
for (SearchResult item : searchResponse.getItems()) {
//this is what i was talking about. My search result item
//is not showing me any playlist id
videoIds.add(item.getId().getVideoId());
}
【问题讨论】:
标签: android youtube youtube-api