简体   繁体   中英

removeTracksFromPlaylist not removing tracks with ios spotify sdk

I was testing this method to remove tracks from a playlist. Basically I modified the demo project "simple track playback" provided with the SDK. I wanted to remove the track form the playlist when you hit fastForward. I changed the fastForward method this way but it's not doing anything, and error is nil.

-(IBAction)fastForward:(id)sender {
    if([self.player isPlaying] && self.currentPlaylistSnapshot){
        SPTAuth *auth = [SPTAuth defaultInstance];
        [self.currentPlaylistSnapshot removeTracksFromPlaylist:@[self.player.currentTrackURI]
                                    withAccessToken:auth.session.accessToken
                                    callback:^(NSError *error) {
                                        if (error != nil) {
                                            NSLog(@"*** Failed to remove track : %@", self.titleLabel.text);
                                            return;
                                        }
                                    }];
    }

    [self.player skipNext:nil];
}

self.currentPlaylistSnapshot is the one I've got from the handleNewSession method.

There's also a static method apparently offering something similar which I have't tried yet.

createRequestForRemovingTracks:fromPlaylist:withAccessToken:snapshot:error:

According to the documentation both options are implemented asynchronously and will take seconds to reflect the results in the server but I'm suspecting that there's either something wrong or I'm just missing to do an actual request to push the changes on the local snapshot maybe?

Documentation: https://developer.spotify.com/ios-sdk-docs/Documents/Classes/SPTPlaylistSnapshot.html#//api/name/removeTracksWithPositionsFromPlaylist:withAccessToken:callback :

ios sdk: https://github.com/spotify/ios-sdk

我通过重置模拟器+添加SPTAuthPlaylistModifyPublicScope解决了我的问题(我可以这样做...)

auth.requestedScopes = @[SPTAuthStreamingScope, SPTAuthPlaylistModifyPublicScope];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM