libSpotify在Android中崩溃

时间:2014-02-22 12:14:22

标签: android spotify libspotify

我正在做一款需要Android版Spotify的应用。但是当我运行libSpotify“sp_session_create”时,我得到一个SIGSEGV。我正在使用的libSpotify版本是v12.1.51 BETA - 对于android ARM

sp_error initialise(const char * asKey,
                    const char * asFolder,
                    const char * asUserAgent,
                    bool isPlaylistCompressed,
                    bool isMetadataOnPlaylist,
                    bool isPlaylistInitialUnload)
{
    sp_session_callbacks asCallbacks;
    memset(&asCallbacks, 0, sizeof(asCallbacks));

    asCallbacks.logged_in                    = Callback::onSessionLogin;
    asCallbacks.log_message                  = Callback::onSessionLog;

    sp_session_config asConfiguration;
    memset(&asConfiguration, 0, sizeof(asConfiguration));

    std::string asDirectory = asFolder;
    auto asDirectoryCache   = asDirectory + "/cache";
    auto asDirectorySetting = asDirectory + "/setting";

    const auto asApplicationKey = "Key goes here...";

    asConfiguration.api_version                      = SPOTIFY_API_VERSION;
    asConfiguration.application_key                  = asApplicationKey;
    asConfiguration.application_key_size             = sizeof(asApplicationKey);
    asConfiguration.cache_location                   = asDirectoryCache.c_str();
    asConfiguration.settings_location                = asDirectorySetting.c_str();
    asConfiguration.user_agent                       = asUserAgent;
    asConfiguration.compress_playlists               = isPlaylistCompressed;
    asConfiguration.dont_save_metadata_for_playlists = isMetadataOnPlaylist;
    asConfiguration.initially_unload_playlists       = isPlaylistInitialUnload;
    asConfiguration.userdata                         = this;
    asConfiguration.callbacks                        = &asCallbacks;

    sp_error asError = sp_session_create(&asConfiguration, &_asSession);

    __android_log_print(ANDROID_LOG_VERBOSE, LIBRARY_NAME, "PASSED");

    return asError;
}

2 个答案:

答案 0 :(得分:0)

修改Spotify's new Android SDK已发布!您应该强烈考虑将项目移动到新SDK,因为该平台现在不推荐使用libspotify。

答案 1 :(得分:0)

崩溃是由缓存文件夹引起的。