Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how I can load a playlist spotify on a player and play song ? #5

Open
angelz07 opened this issue Feb 1, 2015 · 5 comments
Open

how I can load a playlist spotify on a player and play song ? #5

angelz07 opened this issue Feb 1, 2015 · 5 comments
Labels

Comments

@angelz07
Copy link

angelz07 commented Feb 1, 2015

hello,

I try to load a play list in a player (with his player id) and start playing list song of the playlist but I dont see how do that :-)

can you help me

now I test this code but ...

exports.play_playlist = function (playlist_uri) {
console.log(playlist_uri)

//subscribe for the 'register' event to ensure player registration is complete

squeeze.on('register', function () {
    //you're ready to use the api, eg.
    squeeze.getPlayers(function (reply) {
        console.dir(reply);
    });
});
squeeze.on('register', function () {
    //we only need a couple (5) of search results

            //Now let's play the song with our player
            playerIdByName(config.nom_player, function (pl) {
                if (reply.ok) {
                    squeeze.apps.spotify.loadToPlaylist(playlist_uri, pl.playerId, function (reply) {
                        if (!reply.ok) {
                            console.dir(reply);
                        }
                        //if needed, let's adjust the volume
                        squeeze.players[pl.playerId].setVolume(40);
                    //Enjoy listening
                    });
                }
            });

});

}

can you help me please ?

@piotrraczynski
Copy link
Owner

Glad to help,

What is playlist_uri and how do you get it? Can you post console.dir(reply) of this loadToPlaylist?

@piotrraczynski
Copy link
Owner

I've just tested adding playlist and it seems to work. I admit that I haven't implemented playlist querying in the library but when I copied playlist URL from spotify desktop app (right click on playlist and 'copy spotify URI') and passed it as string argument to loadToPlaylist it works just fine, is your playlist url something like this?

spotify:user:youruserid:playlist:66VOb4xsC9yEk7X5DXVXsW

@angelz07
Copy link
Author

angelz07 commented Feb 2, 2015

helle thanks for reply,

ok so the code I have put is ok ?

I use this type of uri : https://api.spotify.com/v1/users/spotify/playlists/3jtuOxsrTRAWvPPLvlW1VR/tracks

@piotrraczynski
Copy link
Owner

Hi,

The code looks ok, (unless player with this name doesn't exist) but the URI you provided probably won't work. Do you have access to standalone, desktop Spotify client (works on Windows/Linux and MAC too I guess)? You're trying to open http URL (probably from web client) and this is not going to work (I haven't tried that but you did and it didn't work). Valid Spotify URI for a playlist should be sth like this:

eg. spotify:user:user_id:playlist:66VOb4xsC9yEk7X5DXVXsW

Try to copy URI from Desktop player instead of URL from web player, and you should be ok. If you don't have access to desktop player, you can try to change my example. Type your user id as user_id above and exchange the playlist hash in my example to yours (3jtuOxsrTRAWvPPLvlW1VR). If Spotify URI templates are consistent (which I assume is true) it should work.

BTW1, I'm working on extending Spotify to support playlist querying, etc. Stay tuned I plan to release new version soon.

BTW2, Try to log the reply also if request failed (reply.ok is false) to see if you even get to this loadToPlaylist function.

Let me know if it started to work for you. If not we'll burn the issue down to the ground.

@dcjona
Copy link

dcjona commented Oct 7, 2020

hi,

any update?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants