C# 我能';youtube上的视频不能通过频道播放,为什么?

C# 我能';youtube上的视频不能通过频道播放,为什么?,c#,wpf,youtube,youtube-api,C#,Wpf,Youtube,Youtube Api,public async System.Threading.Tasks.Task GetYoutubeMusic() { var youtubeService=new youtubeService(new BaseClientService.Initializer() { ApiKey=“…”, ApplicationName=this.GetType().ToString() }); var searchListRequest=youtubeService.Channels.List(“代码段

public async System.Threading.Tasks.Task GetYoutubeMusic()
{
var youtubeService=new youtubeService(new BaseClientService.Initializer()
{
ApiKey=“…”,
ApplicationName=this.GetType().ToString()
});
var searchListRequest=youtubeService.Channels.List(“代码段”);
searchListRequest.Id=“UC-9-kyTW8ZkZNDHQJ6FgpwQ”;
searchListRequest.MaxResults=25;
//调用search.list方法检索结果。。。
var searchListResponse=等待searchListRequest.ExecuteAsync();
列表数组=新列表();
foreach(searchListResponse.Items中的var searchResult)
{
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;
数组。添加(产品);
}
返回阵列;
}
只需从这个频道获取信息,但没有视频。。。
我不明白。请解决它。

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

但是,如果您已经拥有该频道的id,则只需

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;
    }