주어진 트랙 세트의 재생 목록 이미지를 가져 오는 것에 대해 내 마음을 잃어 버렸습니다.Spotify api 1.0.0 지정된 트랙 세트의 재생 목록 이미지 가져 오기
나는 그것을 작동시키지 못합니다.
여기 내 코드가 있습니다.
두 개의 재생 목록이 있습니다. 하나는 지정된 트랙 세트로 구성되고 하나는 실제로 존재합니다.
첫 번째 오류는 무엇을하고 있습니까? 임시 재생 목록을 올바르게 작성하고 있습니까?
require([
'$api/models',
'$views/image#Image',
'$views/list#List'
], function(models, Image, List) {
'use strict';
var image, trackUris, tracks = [], customPlaylist, customPlaylistList;
// list of track uris
trackUris = [
'spotify:track:0jakfggA0WkYpkAXni6pts',
'spotify:track:2g1EMRbn6So6zGTdwNyySf',
'spotify:track:4kNfh9In8hjuuERSZhwTTx',
'spotify:track:1JHUxxd77M4ViaqJZfBdl0',
'spotify:track:6x3db7BbBjDYZH2ZAcvYyC',
'spotify:track:6czyeVTQtHYPnZgXE6op0I',
'spotify:track:51Vyh1xfCD27SneoG7NAhb'
];
// get track objects from uris
for (var i = 0; i < trackUris.length; i++) {
tracks.push(models.Track.fromURI(trackUris[i]));
}
// create temporary playlist
var title = 'tmp_' + Date.now();
var tmp = models.Playlist.createTemporary(title).done(function(playlist){
// get tracks collection and add tracks to it
playlist.load(['tracks']).done(function(){
for (var i = 0; i < tracks.length; i++) {
playlist.tracks.add(tracks[i]);
}
});
customPlaylist = playlist;
}).fail(function() {
console.log("Failed");
});
// create image of playlist
image = Image.forPlaylist(customPlaylist, {width: 200, height: 200, player: true});
document.getElementById('customPlaylistCover').appendChild(image.node);
// create a list view for the playlist
customPlaylistList = List.forPlaylist(customPlaylist);
document.getElementById('customPlaylistList').appendChild(customPlaylistList.node);
customPlaylistList.init();
// get all the above for an existing playlist
var playlist = models.Playlist.fromURI('spotify:user:116690321:playlist:6l3dvYJaGrX5mqkNntbyLx');
image = Image.forPlaylist(playlist, {width: 200, height: 200, player: true});
document.getElementById('playlistCover').appendChild(image.node);
var playlistList = List.forPlaylist(playlist);
document.getElementById('playlistList').appendChild(playlistList.node);
playlistList.init();
});
괜찮 았지만 모자이크가 표시되어야합니다. 맞습니까? 이전 API에서 작동했는데, 왜 이것이 작동하지 않습니까? – Bundy
이전 답변을 다소 확장했습니다. 도움이 되었기를 바랍니다. –
설명해 주셔서 감사합니다. 그러나 문제가 해결되지 않습니다. 나는 이것을 models.Playlist.create ('Test')로 테스트했습니다. done (...); 그리고 매번 작업하는 것이 좋습니다. 하지만 어떤 이유로 임시 재생 목록에서 모자이크를로드 할 수 없습니다. 즉, Echo Nest와 같은 임의 트랙에서 재생 목록을 생성하는 앱을 제작하는 경우 모자이크 이미지를 표시 할 수 없습니다. 주위에있는 유일한 방법은 처음 4 트랙의 이미지 ID를 얻고 배경 이미지를 변경하여 모자이크를 직접 만드는 것입니다. 모자이크 : id1 : id2 : id3 : id4하지만 soo가 잘못된 것 같습니다 :) – Bundy