api记录很差,我很困惑。 sp_search方法接受参数(sp_search * search,int index)。如何创建sp_search对象?
答案 0 :(得分:0)
可以找到libspotify的完整文档here。搜索功能位于“模块”下,然后是“搜索”。
libspotify附带的spshell
示例包含search.c
文件中完整的搜索实现。这是这样做的:
sp_search *newSearch = sp_search_create(session,
"foo fighters", //query
0, // track_offset
100, //track_count
0, //album_offset
100, //album_count
0, //artist_offset
100, //artist_count
0, // playlist_offset,
100, // playlist_count
SP_SEARCH_STANDARD, // search type
&search_complete, //callback
NULL); // userdata
void search_complete(sp_search *result, void *userdata) {
int trackCount = sp_search_num_tracks(search);
for (int currentTrack = 0; currentTrack < trackCount; currentTrack++) {
sp_track *track = sp_search_track(search, currentTrack);
// Do something with track...
}
}