本文整理汇总了C#中Track.SetMatches方法的典型用法代码示例。如果您正苦于以下问题:C# Track.SetMatches方法的具体用法?C# Track.SetMatches怎么用?C# Track.SetMatches使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Track
的用法示例。
在下文中一共展示了Track.SetMatches方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ResolveAsync
public async Task ResolveAsync(Track track)
{
string title;
string artist;
this.PrepareTrack(track, out title, out artist);
var q = $"track:%22{title}%22&artist:\"{artist}\"";
q = PreprocessRequest(q);
var searchItem = await _spotify.SearchItemsAsync(q, SearchType.Track, 50);
LogIfError(q, searchItem);
// if no result found, search for title only
if (searchItem.Tracks?.Items?.Count == 0)
{
await Task.Delay(REQUESTSDELAY); // avoid "API rate limit exceeded"
q = $"track:%22{title}%22";
q = PreprocessRequest(q);
searchItem = await _spotify.SearchItemsAsync(q, SearchType.Track, 50);
LogIfError(q, searchItem);
}
var spotifyTracks = searchItem?.Tracks?.Items
.OrderByDescending(x => x.Popularity)
.Select(x => new SpotifyTrack(x));
if (spotifyTracks != null)
track.SetMatches(spotifyTracks);
}