在Windows上使用libspotify按艺术家搜索?

时间:2013-10-21 02:23:52

标签: windows spotify libspotify

api记录很差,我很困惑。 sp_search方法接受参数(sp_search * search,int index)。如何创建sp_search对象?

1 个答案:

答案 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...
    }
}
相关问题