Spotify API for ios:下载,保存,访问来自ios spotify api的曲目

我想知道是否可以使用spotify ios api(CocoaLibSpotify IOS Library)下载到iphone / ipod / ipad设备的音轨。 如果是这样,我也需要访问他们,随时随地玩我想要的。 我将在以后的应用程序中使用它们。

我想我们可以使用sp_track_offline_status来检查正在播放的曲目的离线状态。 但我无法解决这个问题。

任何示例代码片段都将非常有帮助。

简化要求 :下载并保存到iOS设备的Spotify轨道

作为更新,为了响应iKenndac的回答,offlineStatus属性已经变为'1',这意味着该游戏者被同步用于本地存储。

SP_PLAYLIST_OFFLINE_STATUS_YES = 1,/// <播放列表同步到本地存储

1.这是否意味着播放列表中的所有曲目均已下载?

我不这么认为。 因为还有其他国家如下:

typedef enum sp_playlist_offline_status { SP_PLAYLIST_OFFLINE_STATUS_NO = 0, ///< Playlist is not offline enabled SP_PLAYLIST_OFFLINE_STATUS_YES = 1, ///< Playlist is synchronized to local storage SP_PLAYLIST_OFFLINE_STATUS_DOWNLOADING = 2, ///< This playlist is currently downloading. Only one playlist can be in this state any given time SP_PLAYLIST_OFFLINE_STATUS_WAITING = 3, ///< Playlist is queued for download } sp_playlist_offline_status; 

我从来没有离线状态2或3。

  1. 另外我的offlineDownloadProgress属性总是显示我'0'。
    如果我没有错,它必须从'0'增加到'1'。

CODE片段:

 [SPAsyncLoading waitUntilLoaded:playList timeout:kSPAsyncLoadingDefaultTimeout then:^(NSArray *loadedItems, NSArray *notLoadedItems) { playList.markedForOfflinePlayback = YES; currentPlaylist = playList; statusTimer = [NSTimer scheduledTimerWithTimeInterval:0.3 target:self selector:@selector(checkOfflineStatus) userInfo:nil repeats:YES]; 

我正在检查状态如下:

 -(void)checkOfflineStatus { NSLog(@"playlist offline progress is: %f",currentPlaylist.offlineDownloadProgress); NSLog(@"offline status: %d",currentPlaylist.offlineStatus); } 

输出如下所示:

2012-07-06 20:34:05.891简单播放器[6571:10703]播放列表离线进度是:0.000000

2012-07-06 20:34:05.892 Simple Player [6571:10703]离线状态:1

2012-07-06 20:34:06.039简单播放器[6571:10703]播放列表脱机进度是:0.000000

2012-07-06 20:34:06.039简单播放器[6571:10703]离线状态:1

接下来我可以做什么?

您不能简单地将Spotify曲目下载为MP3文件或其他独立播放的内容。

但是,只要用户保持login到CocoaLibSpotify,就可以让库caching轨道以供离线回放,就像iOS Spotify客户端一样。

SPPlaylist具有markedForOfflinePlayback用于启用离线访问的offlineStatus属性,则播放列表的offlineDownloadProgressofflineStatus属性将提供更多信息。

CocoaLibSpotify附带了一个Mac示例应用程序,它可以caching播放列表进行离线播放,以查看其工作原理。 在Mac OS X和iOS版本的CocoaLibSpotify上,API都是可用的。