【问题标题】:Retrieve Popular Videos In YouTube API V3 Android在 YouTube API V3 Android 中检索热门视频
【发布时间】: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


    【解决方案1】:

    使用 YouTube API V3 的 Developers API 密钥使用以下内容在 YouTube API V3 中检索热门视频:

    https://www.googleapis.com/youtube/v3/videos?chart=mostPopular&key={YOUR_API_KEY}&part=snippet&maxResults=4
    

    【讨论】:

      猜你喜欢
      • 2016-10-26
      • 2017-09-17
      • 2015-07-22
      • 2020-12-29
      • 1970-01-01
      • 2018-04-18
      • 2023-03-09
      • 2013-07-18
      • 2017-09-17
      相关资源
      最近更新 更多