【问题标题】:Search by artist using libspotify on windows?在 Windows 上使用 libspotify 按艺术家搜索?
【发布时间】:2013-10-21 02:23:51
【问题描述】:

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

【问题讨论】:

    标签: windows spotify libspotify


    【解决方案1】:

    可以在 here 找到 libspotify 的完整文档。搜索功能在“模块”下,然后是“搜索”。

    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...
        }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-06-05
      • 2013-04-11
      • 2017-04-27
      • 2018-02-13
      相关资源
      最近更新 更多