简体   繁体   English

removeTracksFromPlaylist不使用iOS Spotify SDK删除曲目

[英]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. 基本上,我修改了SDK随附的演示项目“简单轨道回放”。 I wanted to remove the track form the playlist when you hit fastForward. 当您点击fastForward时,我想从播放列表中删除曲目。 I changed the fastForward method this way but it's not doing anything, and error is nil. 我以这种方式更改了fastForward方法,但是它什么也没做,错误为零。

-(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. self.currentPlaylistSnapshot是我从handleNewSession方法获得的一个。

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 : 文档: https : //developer.spotify.com/ios-sdk-docs/Documents/Classes/SPTPlaylistSnapshot.html#//api/name/removeTracksWithPositionsFromPlaylist :withAccessToken: callback

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

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

auth.requestedScopes = @[SPTAuthStreamingScope, SPTAuthPlaylistModifyPublicScope];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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