对于我的应用程序,我需要在将其转换为快照以便稍后使用之前对其进行随机播放。根据{{3}}方法返回一个新的集合,其轨道是随机的,所以我应该能够立即调用snapshot()方法(因为它不会像snapshot()那样返回Promise)。
这是我的测试代码,它在没有shuffle方法的情况下按预期工作。但是,它在控制台中没有显示任何内容。
playlist.load('tracks').done(function(tracks) {
// Works when shuffle() is removed
playlist.tracks.shuffle().snapshot()
.done(
function( snapshot ) {
console.log( snapshot );
for (var i = 0; i < snapshot.length; i++) {
var track = snapshot.get(i);
console.log(track.name);
}
}
);
});
有什么想法吗?
答案 0 :(得分:1)
看起来像一些雄心勃勃的文档 - 似乎没有实现shuffle。当我跑这个时:
require(['$api/models'], function (models) {
playlist = models.Playlist.fromURI(localStorage.album_radio_playlist);
playlist.load('tracks').done(function (tracks) {
console.log(tracks);
// Works when shuffle() is removed
playlist.tracks.shuffle().snapshot()
.done(
function (snapshot) {
console.log(snapshot);
for (var i = 0; i < snapshot.length; i++) {
var track = snapshot.get(i);
console.log(track.name);
}
}
).fail(function (blah, err) { console.log("failed to shuffle " + err); });
});
});
我得到了这个输出
14:46:05.156 A [shell/lists/ItemListFactory.h:239] Check failed: Not implemented!
14:46:05.167 I [sp://67456db3aaa5a1c25a619472cdb2cbc3f52da3ed.album-radio/js/albumradio.js:684] failed to shuffle undefined