Spotify的API适用于iOS:下载,保存,从IOS Spotify的API访问轨迹 [英] Spotify API for ios: download , save , access tracks from ios spotify api

查看:239
本文介绍了Spotify的API适用于iOS:下载,保存,从IOS Spotify的API访问轨迹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否下载曲目在iPhone / iPod / iPad设备是可以使用Spotify的IOS API(CocoaLibSpotify IOS库)。如果是这样我也需要访问它们并发挥随时想。我会在我的应用程序使用它们更高版本。

I would like to know whether downloading tracks to the iphone / ipod / ipad devices is possible using the spotify ios api (CocoaLibSpotify IOS Library). If so I also need to access them and play anytime I want. I will be using them in my app later.

我想,我们可以检查正在使用sp_track_offline_status播放曲目的脱机状态。但我无法通过该得到的。

I think we can check the offline status of the track that is being played by using sp_track_offline_status. But I am unable to get through that.

任何样品code段会有很大的帮助。

Any sample code snippet would be of great help.

简化的要求:下载和Spotify的曲目保存到iOS设备

Simplifying the requirement: download and save the spotify tracks into iOS devices

作为一个更新,响应于iKenndac的回答时,offlineStatus属性已成为1,这意味着playist是用于本地存储同步。

As an update, in response to iKenndac's answer, the offlineStatus property has become '1' which means that the playist is synchronised for local storage.

SP_PLAYLIST_OFFLINE_STATUS_YES = 1,///&下;播放列表被同步到本地存储

SP_PLAYLIST_OFFLINE_STATUS_YES = 1, ///< Playlist is synchronized to local storage

这指的是在播放列表中的所有曲目1.Does下载?

1.Does that mean all the tracks in the playlist are downloaded?

我不这么认为。因为有其他规定如下:

I dont think so. because there are other states as follows:

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;

我从来没有得到offlineStatus 2或3。

I had never got the offlineStatus either 2 or 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);

}

输出看起来是这样的:

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

2012-07-06 20:34:05.891 Simple Player[6571:10703] playlist offline progress is: 0.000000

20 2012-07-06:34:05.892简单的播放器[6571:10703]脱机状态:1

2012-07-06 20:34:05.892 Simple Player[6571:10703] offline status: 1

20 2012-07-06:34:06.039简单的播放器[6571:10703]离线播放进度为:0.000000

2012-07-06 20:34:06.039 Simple Player[6571:10703] playlist offline progress is: 0.000000

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

2012-07-06 20:34:06.039 Simple Player[6571:10703] offline status: 1

我能做些什么下?

推荐答案

您不能简单地下载Spotify的跟踪端口,比如,MP3文件或任何独立播放。

You can't simply download Spotify tracks as, say, MP3 files or whatever for independent playback.

但是,作为用户保持登录到CocoaLibSpotify,就像iOS的Spotify的客户端不,你可以有脱机播放库缓存轨道后,只要。

However, you can have the library cache tracks for offline playback later, as long as the user stays logged into CocoaLibSpotify, just like the iOS Spotify client does.

SPPlaylist 已启用离线访问,那么 offlineDownloadProgress markedForOfflinePlayback 属性code>和 offlineStatus 播放列表的性质给出更多的信息。

SPPlaylist has the markedForOfflinePlayback property for enabling offline access, then the offlineDownloadProgress and offlineStatus properties of the playlist give more information.

CocoaLibSpotify附带了播放列表缓存对于脱机播放,看看它是如何工作的是Mac示例应用程序。该API可和CocoaLibSpotify的在Mac OS X和iOS的版本是一样的。

CocoaLibSpotify comes with a Mac sample application that caches playlists for offline playback to see how it works. The API is available and the same on both Mac OS X and iOS versions of CocoaLibSpotify.

这篇关于Spotify的API适用于iOS:下载,保存,从IOS Spotify的API访问轨迹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆