【发布时间】:2012-07-06 01:38:33
【问题描述】:
我想知道是否可以使用 spotify ios api(CocoaLibSpotify IOS 库)将曲目下载到 iphone / ipod / ipad 设备。如果是这样,我还需要访问它们并随时播放。稍后我将在我的应用中使用它们。
我想我们可以使用 sp_track_offline_status 检查正在播放的曲目的离线状态。但我无法度过难关。
任何示例代码 sn-p 都会有很大帮助。
简化要求:下载Spotify曲目并将其保存到iOS设备中
作为更新,为了响应 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。
- 我的 offlineDownloadProgress 属性也总是显示“0”。
如果我没记错的话,它必须从“0”增加到“1”。
代码 sn-p:
[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 Simple Player[6571:10703] 播放列表离线进度为:0.000000
2012-07-06 20:34:05.892 Simple Player[6571:10703] 离线状态:1
2012-07-06 20:34:06.039 Simple Player[6571:10703] 播放列表离线进度为:0.000000
2012-07-06 20:34:06.039 简单播放器[6571:10703] 离线状态:1
接下来我能做什么?
【问题讨论】: