问题
Is it possible to set a custom image on the views.player? I've tried to change the player.image.node but I don't get it to work. Any ideas?
Thanks
回答1:
This is what I'm doing. Not sure if it is the official way but it works.
var player = new views.Player();
var image = new views.Image(img_url, spotify_uri, title);
$(player.node).find('.sp-player-image').replaceWith(image.node);
$('.player_div').append(player.node);
I would love to hear if anyone has a better solution.
回答2:
Yes, the documentation about the views are quite undocumented.
Here's how you use the view to generate the album widget.
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="sp://import/css/eve.css">
<link rel="stylesheet" href="sp://import/css/api.css">
</head>
<div id="album-element"></div>
<script>
var sp = getSpotifyApi(1);
var views = sp.require('sp://import/scripts/api/views');
var models = sp.require('sp://import/scripts/api/models');
models.Album.fromURI('spotify:album:6HbNEBza64W10MQxUFq6QL', function(album) {
var p = new views.Player();
p.context = album;
document.getElementById('album-element').appendChild(p.node);
});
</script>
</body>
</html>
来源:https://stackoverflow.com/questions/9547337/views-player-album-cover