简体   繁体   English

使用Spotify Apps API从给定播放列表中的特定曲目开始

[英]Start at specific track in given playlist with Spotify Apps API

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. 我正在尝试使用Spotify API开始特定的曲目,但是无论我做什么,我似乎都无法正常工作。 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 以下是API文档: 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'));
});

The playContext documentation states that the method takes four parameters, the second one being the index. playContext文档指出该方法采用四个参数,第二个为索引。

The first item in the context to play. 上下文中要播放的第一项。 This must be a positive number. 这必须是一个正数。 If left out, the first playable item in the context will start playing. 如果省略,则上下文中的第一个可播放项目将开始播放。

Using your code snippet: 使用您的代码段:

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

The index starts from 0, so this example would play the third track in the playlist. 索引从0开始,因此本示例将播放播放列表中的第三首曲目。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM