我正在尝试使用 Spotify Objective-C 库来搜索属于某个艺术家、专辑的特定歌曲。我不想使用 searchWithSearchQuery 方法(可以正常工作),因为我想更具体。有一个名为 searchWithURL 的方法,如下所示。我没有看到任何有关如何构建这些 URL 的文档。它只是说它必须以 Spotify:search 开头。之后会发生什么?如何指定艺术家、专辑、歌曲?谢谢!
/** Creates a new SPSearch with the default page size from the given Spotify search URL.
This convenience method is simply returns a new, autoreleased SPSearch
object. No caching is performed.
@warning If you pass in an invalid search URL (i.e., any URL not
starting `spotify:search:`, this method will return `nil`.
@warning The search query will be sent to the Spotify search service
immediately. Be sure you want to perform the search before creating the object!
@param searchURL The search URL to create an SPSearch for.
@param aSession The SPSession the track should exist in.
@return Returns the created SPSearch object.
*/
+(SPSearch *)searchWithURL:(NSURL *)searchURL inSession:(SPSession *)aSession;
最佳答案
搜索 URL 由 SPSearch
实例在您创建后创建,它们基本上对您第一次传递的查询进行编码。因此,searchWithURL:
对您而言不会比使用查询创建搜索更有用。
但是,要回答更广泛的问题,您可以使用 Spotify Advanced Search Syntax使用 SPSearch
进行更准确的搜索。
例如,要查找完全名为“Roar”的轨道:
[SPSearch searchWithSearchQuery:@"track:Roar"
inSession:[SPSession sharedSession]];
要查找 Katy Perry 的名为“Roar”的轨道:
[SPSearch searchWithSearchQuery:@"track:Roar artist:\"Katy Perry\""
inSession:[SPSession sharedSession]];
...等等。查看链接页面了解更多详细信息。
关于iphone - Cocoalibspotify 搜索特定歌曲,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20432642/