我不能通过频道在youtube上播放视频。为什么?

时间:2015-06-03 15:35:43

标签: c# wpf youtube youtube-api

https://www.youtube.com/channel/UC-9-kyTW8ZkZNDHQJ6FgpwQ

public async System.Threading.Tasks.Task<List<ViewModel.YoutubeVideo>> GetYoutubeMusic()
    {
        var youtubeService = new YouTubeService(new BaseClientService.Initializer()
        {
            ApiKey = "....",
            ApplicationName = this.GetType().ToString()
        });


        var searchListRequest = youtubeService.Channels.List("snippet");
        searchListRequest.Id= "UC-9-kyTW8ZkZNDHQJ6FgpwQ";
        searchListRequest.MaxResults = 25;



        //Call the search.list method to retrieve results...
        var searchListResponse = await searchListRequest.ExecuteAsync();
        List<ViewModel.YoutubeVideo> arrays = new List<ViewModel.YoutubeVideo>();
        foreach (var searchResult in searchListResponse.Items)
        {
            product = new ViewModel.YoutubeVideo();
            product.id = searchResult.Id;
            product.Name = searchResult.Snippet.Title;
            product.Thumb100Uri = searchResult.Snippet.Thumbnails.Default.Url;
            product.Thumb200Uri = searchResult.Snippet.Thumbnails.Medium.Url;
            arrays.Add(product);

        }

        return arrays;
    }

只是从这个频道获取信息,但没有视频...... 我不明白这一点。请解决它。

1 个答案:

答案 0 :(得分:0)

因为您没有调用search.list方法。您正在代码中调用channels.list方法。

但如果您已拥有频道的ID,则应retrieve that channel's uploaded videos