Reputation: 493
I am trying to code a spotify app which is a music quiz. So I need to start songs at a specific time and make them end to another specific time. I don't know how to do it at all ! The spotify Uri with the # don't work. I have tried this code and it makes the song starting from the beginning :
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);
Thanks for your help !
Upvotes: 1
Views: 5339
Reputation: 654
try something simpler:
var player = new views.Player();
player.PlayTrack('spotify:track:0blzOIMnSXUKDsVSHpZtWL', 60000, 10000);
This plays 10 seconds of the track starting at the 1minute mark.
Upvotes: 1