0

Im trying to start a specific track using spotify API, but no matter what i do, i can't seem to get it to work. I don't understand the documentation and where to place the track index.

here is the API documentation: https://developer.spotify.com/docs/apps/api/1.0/api-models-player.html

require(['$api/models'], function(models) {
  models.player.playContext(models.Playlist.fromURI('spotify:user:cevil:playlist:5f4EBgrnSf86Hr86kL4S90:index:5'));
});
4

1 回答 1

1

playContext 文档指出该方法有四个参数,第二个是索引。

上下文中要播放的第一个项目。这必须是一个正数。如果省略,上下文中的第一个可播放项目将开始播放。

使用您的代码片段:

require(['$api/models'], function(models) {
  var index = 2;
  models.player.playContext(models.Playlist.fromURI('spotify:user:cevil:playlist:5f4EBgrnSf86Hr86kL4S90'), index);
});

索引从 0 开始,因此本示例将播放播放列表中的第三首曲目。

于 2014-06-19T09:49:50.717 回答