在Spotify的删除从播放列表中的曲目 [英] Remove tracks from playlist in spotify

查看:2944
本文介绍了在Spotify的删除从播放列表中的曲目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

要删除从播放列表所有歌曲到选择的歌曲。这code崩溃Spotify的,所以我不能看到的抱怨是什么,但我相信它一旦发生的第一次调用删除轨道发生。如果我注释掉删除呼叫,记录看起来是正确的。

Want to delete all songs from the playlist up to the selected song. This code is crashing Spotify so I can't see what the complaint is but I believe its happening as soon as the first call to remove the track happens. If I comment out the remove call, the logging looks correct.

    var playlist = models.Playlist.fromURI(uri);
    playlist.load('tracks').done(function (tracks) {
        console.log('tracks loaded');
        playlist.tracks.snapshot(0, 20).done(function (snapshot) {
            console.log('snapshot loaded');
            if(snapshot.find(models.player.track)) {
                var done=false;
                var tracks = snapshot.toArray();
                tracks.forEach(function(deleteme) {
                    if (deleteme == models.player.track) {
                        console.log('here\'s our current track');
                        done = true;
                    } else if (done) {
                        console.log('already done');
                    } else {
                        console.log('deleting ' + deleteme.uri);
                        playlist.tracks.remove(deleteme);
                    }
                })
            }
        });
    });

更新
不知道发生了什么,但它不再崩溃。也许是因为我运行命令行Spotify的-console。

Update Not sure what happened, but its no longer crashing. Maybe because I'm running spotify -console from the command line.

现在我得到这个消息,而不是。

Now I get this message instead.

20:39:36.663 A [base/range.h:27                 ] Check failed: loc >= 0:

Promise.fail的错误消息指出的在指数-1项目改变。

推荐答案

显然 snapshot.toArray()的元素是不一样的快照.REF(指数)

Apparently elements of snapshot.toArray() are not the same as snapshot.ref(index).

更新:参考文档,使我明白这一点 - https://developer.spotify.com/docs/apps/api/1.0/api-models-reference.html

Update: reference documentation that made me understand this - https://developer.spotify.com/docs/apps/api/1.0/api-models-reference.html

这篇关于在Spotify的删除从播放列表中的曲目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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