我想在youtube上学习搜索API。我使用了示例项目,我想改进它。示例顺序,视频时长
searchListRequest.VideoDuration = SearchResource.ListRequest.VideoDurationEnum.Medium;

中
附加信息:调用目标引发了异常。
这是错误的。我将如何使用VideoDuration
我试过
searchListRequest.VideoDuration = "Medium";

这给了 错误CS0029无法隐式转换类型'字符串'到了Google.Apis.YouTube.v3.SearchResource.ListRequest.OrderEnum?'
我的所有代码是;
var youtubeService = new YouTubeService(new BaseClientService.Initializer()
{
ApiKey = "xxxx",
ApplicationName = this.GetType().ToString()
});
var searchListRequest = youtubeService.Search.List("snippet");
searchListRequest.Q = "Google"; // Replace with your search term.
searchListRequest.MaxResults = 50;
switch (videoduration.SelectedIndex) //Combobox
{
case 0 :
searchListRequest.VideoDuration = SearchResource.ListRequest.VideoDurationEnum.Any;
break;
case 1:
searchListRequest.VideoDuration = SearchResource.ListRequest.VideoDurationEnum.Short__;
break;
case 2:
searchListRequest.VideoDuration = SearchResource.ListRequest.VideoDurationEnum.Medium;
break;
case 3:
searchListRequest.VideoDuration = SearchResource.ListRequest.VideoDurationEnum.Long__;
break;
}
// Call the search.list method to retrieve results matching the specified query term.
var searchListResponse = await searchListRequest.ExecuteAsync();
List<string> videos = new List<string>();
List<string> channels = new List<string>();
List<string> playlists = new List<string>();
// Add each result to the appropriate list, and then display the lists of
// matching videos, channels, and playlists.
foreach (var searchResult in searchListResponse.Items)
{
richTextBox1.AppendText(searchResult.Snippet.Title + Environment.NewLine);
richTextBox1.AppendText("https://youtu.be/"+ searchResult.Id.VideoId + Environment.NewLine);
richTextBox1.AppendText(Environment.NewLine);
}
&#13;