我正在尝试编写一个Spotify应用程序,这是一个音乐测验。所以我需要在特定时间开始播放歌曲并让它们结束另一个特定的时间。我根本不知道怎么做!使用#来点击Uri不起作用。 我尝试过这段代码,它使歌曲从头开始:
var sp = getSpotifyApi();
var models = sp.require("$api/models");
var views = sp.require("$api/views");
var single_track = models.Track.fromURI('spotify:track:0blzOIMnSXUKDsVSHpZtWL#01:00');
var single_track_playlist = new models.Playlist();
single_track_playlist.add(single_track);
var single_track_player = new views.Player();
single_track_player.track = null; // Don't play the track right away
single_track_player.context = single_track_playlist;
/* Pass the player HTML code to #single-track-player */
var single_track_player_HTML = document.getElementById('single-track-player');
single_track_player_HTML.appendChild(single_track_player.node);
感谢您的帮助!
答案 0 :(得分:1)
尝试更简单的方法:
var player = new views.Player();
player.PlayTrack('spotify:track:0blzOIMnSXUKDsVSHpZtWL', 60000, 10000);
从1分钟开始播放10秒的曲目。
答案 1 :(得分:0)
Spotify的ToS不允许测验或游戏应用。