How to achieve crossfading on a Spotify javascript based app?
I'm creating a temp playlist and adding songs to it on the fly, the added song plays but doesn't crossfade.
EDIT: I guess the real question is how to cause Spotify to do a refresh of the play queue. the added songs get added to the visible play queue only on the track change, which makes it not crossfade.
There is currently no programmatic access to crossfading in a spotify app (https://developer.spotify.com/technologies/apps/docs/beta/f19ff300f8.html)
However, if the user has crossfading enabled (Settings->Playback->Crossfade tracks) and the model.Player is playing from a context with multiple tracks (like a Playlist or Album) then crossfading should kick in.
The caveat here is that you have to have the next song in the playlist added early-on enough so that the client has time to recognize the change in the playlist. One way to verify if you're adding this in time is to ensure the 'Play Queue' shows that it will play the next song in your playlist.
Related
When Siri is asked "play music by ARTIST_NAME on Spotify" she starts playing music from a playlist that is generated by Spotify, with no displayed name, and the description "ARTIST_NAME songs picked just for you". I cannot find a way to find this playlist. Its name, according to the https://api.spotify.com/v1/me/player endpoint, is ARTIST_NAME, and its owner is Spotify. How can I find this playlist for a given artist using the Web API?
Ultimately, I am trying to work around the fact that if there is no available device (i.e. Spotify is idle or closed) an artist cannot be played by setting a context-uri in the https://api.spotify.com/v1/me/player/play endpoint. To work around this issue in the case of playing a playlist that the user of my program searches for, I have simply opened the URL of the first track in the album or playlist. This doesn't work in the case of artists, since the list of top tracks by an artists gives the tracks' URLs in the context of the respective tracks's album.
If there is no way to access this Siri exclusive playlist, I would appreciate feedback suggesting alternate routes. It is not sufficient to simply create a playlist, since they would be static and have to be recreated for each request.
Thank you.
I want to create a program that, if called, will access my liked songs playlist on Spotify and play either a random song or a song that has been called. I know that I should use the Spotify library, however, I don't really know how to achieve my goal, as most tutorials are about creating a new playlist or something of that nature, not accessing an already present playlist like liked songs.
Any advice will be appreciated:)
You could use the pyspotify library. This part of the documentation goes in detail on how to play music and mess with playlists.
I need to know when the user changes the song that is "currently playing".
Currently, I'm using https://api.spotify.com/v1/me/player/currently-playing to get the information about the song that is "currently playing". But, I need to know when it changes to the next one (not only because the song finished, but also when the user press NEXT SONG button).
My current workaround is to call the https://api.spotify.com/v1/me/player/currently-playing endpoint every second, but I'll be out of the rate limit if I do it very often.
You are doing it right. You need to poll the https://api.spotify.com/v1/me/player/currently-playing endpoint to detect changes in the playback state.
In some scenarios it can be suitable to use Spotify's web playback SDK, which exposes a player_state_changed event. For this to work the user needs to have a premium account and the playback needs to happen on the device created by the SDK.
As you might know, the permission system from Spotify isn't the best. You can just mark a playlist collaborative, and every single spotify user can edit the Playlist without my approval. Therefore, I am writing an application (using Spotify Web Api, node and mysql) that gives the user more control over the collaborative playlists. It should support sub-playlists, votes and a small permission system, which allows just some users to modify the playlist.
In order for that to work, I need a service running all the time in the background. This service should sync my version of the playlist with spotify. Because the user, who owns the playlist, will most likely not be logged in, i have created a special Spotify User for my service. Now, i have to edit the collaborative Playlist using this spotify user.
When i try to delete some Tracks from such a playlist, i get the following answer:
{
"error" :
{
"status" : 403,
"message" : "You cannot remove tracks from a playlist you don't own."
}
}
Do you know if there is a way to delete a Track from a playlist i don't own? And if not, Do you have any idea how to get around this problem?
Do you know if there is a way to delete a Track from a playlist i don't own?
This isn't possible, even if the playlist is collaborative.
And if not, Do you have any idea how to get around this problem?
One way is to create a playlist owned and edited by a user that you control. Server-side you'd keep an access token for that user, and simply refresh it when necessary. Since the refresh token lasts forever, you'd never have to require a user to go through any form of authentication flow.
Hope this helped!
I'm working on a Spotify app where I'd like for users to be able to click on track names and be linked to the track page, just like in other Spotify apps. I'd like to prevent the song from beginning playback, though.
SoundDrop seems to do this. You can click on a track name and the song doesn't interrupt playback by SoundDrop.
I'm not sure how to implement this alternative behavior. Any ideas?
The Apps API uses standard JavaScript stuff, so if you attach a handler to the track link and use e.preventDefault(), that should prevent Spotify playing the track and you can then do your own custom handling.
More discussion on e.preventDefault() is here: event.preventDefault() vs. return false