Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature requests: working with playlists #131

Closed
hspinks opened this issue May 31, 2019 · 10 comments
Closed

Feature requests: working with playlists #131

hspinks opened this issue May 31, 2019 · 10 comments
Labels
suggestion Suggest a change to the SDK

Comments

@hspinks
Copy link

hspinks commented May 31, 2019

First off, just want to say that this SDK has been great to work with, and it's awesome that Spotify offers an SDK to build on top of an already great product! Appreciate all of the work that has gone into building & maintaining this.

One thing that is critical to my use of this SDK that is missing, however, is the ability to work with specific playlists. In the application I'm building, I need to (1) display a (known) subset of playlists from the list of all the user’s playlists, and (2) when the user chooses a playlist, play that playlist starting at a particular song/index in that playlist. There are a couple of challenges with both tasks in the current SDK, and I’d love to request some features to help with this!

Challenge: Getting a list of user’s playlists is clunky

The best way that I’ve found so far to get a list of a user’s playlists requires traversing a tree of content items through 3 calls in succession of -fetchRootContentItemsForType:callback: and -fetchChildrenOfContentItem:callback:. Essentially, I start with a -fetchRootContentItemsForType with the default type, scan the results for a “Your Library” content item, use that item as the parameter for -fetchChildrenOfContentItem, scan those results for a “Playlists” content item, and then use that as the parameter for a final -fetchChildrenOfContentItem call. While this process does work, it feels a little risky because it depends on a predictable title and/or URI pattern for the “Your Library” and “Playlists” content items - if Spotify ever changes those, then the code that traverses the tree would break.

Alternatively, I could query the web API for playlists, but then I wouldn’t be able to take advantage of the offline functionality of this SDK, and also, that would not give me a full-fledged SPTAppRemoteContentItem object which is needed for the -playItem:skipToTrackIndex:callback: method.

Proposed Solution

Add a new -fetchContentItemsForType:callback: method spec to the SPTAppRemoteContentAPI protocol that can directly query lists of content items for things like playlists in a user’s library (but could also work for other types, such as albums/artists/podcasts in a user’s library, or the home/browse/recently played items). The SPTAppRemoteContentTypes can be expanded to support these additional types, or a new enum could be created for these queries.

Challenge: No way to get all of a user’s playlists

Even after following the above method to get a list of playlists, it only gets maximum 20 child content items from the user’s playlists, and it doesn’t seem like there’s a way to get more. If the specific playlists that I’m looking to display to the user are outside of their first 20 in their ordering, then there’s no way that I can display these playlists. Again, querying the web API isn’t an option for the same reasons as above.

Other issues referencing this: #109

Proposed Solution

Add a paging mechanism to the -fetchChildrenOfContentItem method. In simplest form, that could just be adding an offset parameter to the method.

Challenge: Playing an item from a particular index requires an SPTAppRemoteContentItem object

The -playItem:skipToTrackIndex:callback: method works great, but it requires passing in an SPTAppRemoteContentItem object as a parameter. Given the first 2 challenges, it’s clunky at best to get that object, and at worst it’s impossible for any playlist outside of a user’s first 20.

Alternatively, it’s possible to use the -play:callback: method using the playlist’s URI, but that doesn’t allow the capability to start at a specific index. I could follow the -play call with a bunch of -skipToNext calls until I’m at the right index, but that seems pretty clunky too... what if there are hundreds or thousands of songs on the playlist?

Other issues referencing this: #113, #63, #41

Proposed Solution(s)

If the first 2 challenges are addressed, then no solution would be needed here… these would still help though!

Add a -playURI:skipToTrackIndex:callback: method spec to the SPTAppRemotePlayerAPI protocol that can play a resource by URI starting at a particular track index.

Also, add a -fetchContentItemForURI: method spec to the SPTAppRemoteContentAPI protocol that can fetch a SPTAppRemoteContentItem object directly from a URI. This would allow for checks for whether the item is playable and/or available offline if needed.

@kkarayannis kkarayannis added the suggestion Suggest a change to the SDK label Jul 3, 2019
@kkarayannis
Copy link

Hi @hspinks and thank you for the detailed report. The next version of the SDK will implement your fetchContentItemForURI suggestion. It seems like it would solve a lot of problems for you and other people.

@dataexcess
Copy link

dataexcess commented Jul 31, 2019

Hi @kkarayannis,

I would also like to know how to do this. Start an album at a certain track-index given the album's Spotify URI. BUT not necessarily a user album, just an online album (not yet saved by the user) - how should I start to implement this? I cannot fetch/traverse content-items because this is only user-based content - Am i right?

I need this to be implemented urgently so any help much appreciated :)

thank you!

@ctissier
Copy link

ctissier commented Sep 26, 2019

Hello @hspinks, thanks for having done such a detailed report. It covers lots of concerns I also have with my current app development, i'm really glad you did it as it seemed to have convinced the SDK devs to implement a fetchContentItemForURI method (at least).

About that, @kkarayannis, I'm very happy with your intend to include that method in the next version of the SDK. May we ask when it will be published?

@kkarayannis
Copy link

Hi @ctissier,
We don't want to commit to a date, but the goal is to have an update out sometime in the next month. We wanted it to be out sooner but there were some issues with iOS 13 that needed fixing before that could happen.

@ctissier
Copy link

ctissier commented Sep 26, 2019

@kkarayannis

We don't want to commit to a date

I understand of course (sometimes we all want to be able not to commit to a date :)).

Thanks for your quick answer and I'll be waiting for the next version to be fully ready, no hurry. I just wanted to know if it was a matter of a few weeks or a few months. It looks like it's more likely a matter of a few weeks, that'd be perfect.

Keep up the good work.

@sbrighiu
Copy link

Any ETA @kkarayannis .. i'm currently in real need of this feature

@kkarayannis
Copy link

Not yet, I'm afraid.

@kkarayannis
Copy link

This is now available in the newest version:
https://github.com/spotify/ios-sdk/blob/master/SpotifyiOS.framework/Versions/A/Headers/SPTAppRemoteContentAPI.h#L71

@ctissier
Copy link

Great! Thanks a lot, I'll try that ASAP.

@CThuleHansen
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
suggestion Suggest a change to the SDK
Projects
None yet
Development

No branches or pull requests

6 participants