How can I link different tracks present in a particular tab on spotify page, so that when clicked on spotify next/previous button the next/previous track is played. Presenlty it is not playing anything if clicked on next button, when it should be starting to play the next track present on the page
My script looks like this,
$.each(allTracks,function(index,track){
models.Track.fromURI(track, function(track) {
models.Album.fromURI(track.album.uri, function(album) {
var single_track = models.Track.fromURI(track.uri);
var single_track_playlist = new models.Playlist();
single_track_playlist.add(single_track);
var pl = new views.Player();
pl.context = single_track_playlist;
if(index==0) {
$("#firstTrack").append(pl.node);
}
.............
.............
Can anyone please guide me on how I should be going around doing this? Thank you in advance
In your case, the context of each Player view is a playlist with that single track. If you want to render your tracks as players, and have them synchronized so that the next track plays after the one before ends, you need to create a custom solution.
You can check this Grid Play Spotify App, that shows an example of how to achieve it. It basically creates custom Player views that respond to certain events triggered by the Player model and other Player views.
Related
So I'm coding a music player and don't want to use their defualt mediaplayer control panel.
I have a slider object (SeekBar) and I know I can update it to display the postion i am in a current song as such:
SeekBar.Value = (int)PlayMusic.Position.TotalMilliseconds;
So when I call the above the bar move to the exact position I need it to be
So how can I start a thread (async method?) that calls a function that loops the above every millisecond. I'm pretty new and have been trying this for a while.
I have the following code which works for Google Play Music, partly for Poweramp, not at all for stock music player
public void playSelectedPlaylist(String plid) {
Intent intent = new Intent( MediaStore.INTENT_ACTION_MEDIA_PLAY_FROM_SEARCH);
intent.putExtra(MediaStore.Audio.Playlists.ENTRY_CONTENT_TYPE,
"android.intent.extra.playlist" );
intent.putExtra(MediaStore.EXTRA_MEDIA_FOCUS, "vnd.android.cursor.item/playlist");
intent.putExtra(SearchManager.QUERY, plid);
if (intent.resolveActivity(getPackageManager()) != null) {
startActivity(intent);
}else{
doToast("Sorry, no app was found to service this request", context);
}
}
The intent is INTENT_ACTION_MEDIA_PLAY_FROM_SEARCH and it finds all those apps that have this in their manifest.xml file. So far so good. However, some of these are not really suitable for mp3 playlists such as Youtube.
Question 1:
How can I return just music players. (the MUSIC_PLAYER activity has been deprecated so I need to use seomething else)
Question 2:
when executing the above code Poweramp does present the user with the appropriate playlist. When clicking this and select "Play" nothing happens other than Poweramp asking me if I want to play filtered or play all. Selecting either has no effect.
Finally the question, why does Poweramp not play the playlist?
Additional:
the reason why the stock music player does not show is because it does not have the INTENT_ACTION_MEDIA_PLAY_FROM_SEARCH. (I assume this will change in later versions)
Google Play Music has no problem and happily loads and starts to play the playlist
My Samsung has another music player which loads but seems unable to recognise it is a playlist I am passing and does not find anything although the playlist exists.
Anyone with suggestions, thoughts/suggestions I can try out?
Has anyone got the addToCollectionButton working?
var album = models.Album.fromURI('spotify:album:37uqAKt9dLsLob7yomDWY4');
var button = buttons.AddToCollectionButton.forItem(album);
document.getElementById('AddToCollectionButton').appendChild(button.node);
This adds a green button with plus sign, so far so good.
But when I click it, it doesn't do anything.
Anyone with the same problem?
The AddToCollection button is related to the Collection feature, presented in December last year. So at this point in time it's not the correct button for what you want to do.
If you want to add an album to a user's playlist, you could create a button that adds that album as a playlist to the user's library. The SubscribeButton can be used if you want a button that lets the user subscribe/follow a playlist (among other things).
When I embed a Spotify playlist, the oldest tracks come up on top. Is there any way to to make the newest tracks come up on top instead?
Well, the Play button (I assume that's what you're using) displays the playlist in the playlist's order - if the user manually drags tracks to the top, they'll be at the top.
The problem here is that by default, the Spotify clients add new tracks to the end of the playlist. Changing that would need a change in the Spotify clients, which obviously is beyond the scope of this problem.
I'm trying to play a song from a position other than the beginning of the track.
I've found that player.position = X will work as a standalone function, such as triggered by a button, but triggering it on player.observe(models.EVENT.CHANGE... results in a crash.
I figure this is because the track hasn't actually started playing once the event occurs as the player.position may still be at the previous song's position.
I've also experimented with sp.trackPlayer.seek() which seems to give the same results.
So has anyone got a song to start playing at another position than 0? (Or made the playhead jump ahead after the event of playing a new song?)
Add the position after the uri, for example:
var uri= 'spotify:track:xxxxxx#02:04'
player.playTrackFromUri(uri)
See this sourcecode if you want inspiration:
https://github.com/Iteam1337/Wejay/blob/master/javascript/room.js