title: Playing playlists and tracks with Spotify SDK for Android
body: <p>I am having some trouble getting Spotify playlists to play with the beta Spotify SDK. I am, somewhat, following <a href="https://developer.spotify.com/technologies/spotify-android-sdk/tutorial/" rel="nofollow">this tutorial</a> on playback with the Spotify Player class. Unlike in the example, though, I want to play tracks and playlists provided by the user, so I must collect user tracks and playlist data, which I have done with <a href="https://github.com/kaaes/spotify-web-api-android" rel="nofollow">Kaaes Android Web Wrapper</a>. Having collected the data I need, I try to build the Spotify player (which seems to build fine), then from a separate method, attempt to play a track or playlist. Interestingly, I am able to get a track to play back only if I call it during the build process (like it is in tutorial), but not called from another method, and I cannot get playlists to play at all. I get an error while attempting to play playlists that reads:</p>
  
  <pre><code>com.spotify.sdk.android.player.NativeSpotifyException: Failed SpPlayUri with error code 5 (An unexpected argument value was passed to a function)
  </code></pre>
  
  <p>The syntax for playlist that I pass to the play method looks like:</p>
  
  <pre><code>spotify:playlist:4vDeSXEwfHMYOuQaTtwlUK
  </code></pre>
  
  <p>which is similar to track's:</p>
  
  <pre><code>spotify:track:2TpxZ7JUBn3uw46aR7qd6V
  </code></pre>
  
  <p>That could, of course, be incorrect, but it's hard to find examples online of how to play playlists on the Android SDK. So can anyone please show me how to play playlists and how to play content on the Spotify Player object, especially away from the Player builder? I will provide some relevant section of my work below. FWIW, I am handling authentication from another activity, and it hasn't given me too many problems yet...</p>
  
  <pre><code>private PlayerState                         state;
  private Player                              player;
  ...
  public void buildPlayer(){
      //start a Spotify player
      Config playerConfig = new Config(this, token, client_id);
      Spotify.getPlayer(playerConfig, this, new Player.InitializationObserver() {
          @Override
          public void onInitialized(Player p) {
              player = p;
              player.addPlayerNotificationCallback(SpotifyPlayer.this);
              player.setPlaybackBitrate(PlaybackBitrate.BITRATE_NORMAL);
              player.getPlayerState(new PlayerStateCallback() {
                  @Override
                  public void onPlayerState(PlayerState playerState) {
                      state = playerState;
                  }
              });
          }
          @Override
          public void onError(Throwable throwable) {
              Log.e(ID, "Could not initialize player: " + throwable.getMessage());
          }
      });
  }
  
  ...
  public void test(){
      try {
          player.play("spotify:track:2TpxZ7JUBn3uw46aR7qd6V");
          //oddly enough, the track fails to play here, but not if I have this line in the builder
      }catch (Exception e){
          System.out.println("player failed to play");
          e.printStackTrace();
      }
  }
  </code></pre>
  
  <p>There is more stuff going on in this class, but none of that should interfere right now. I look forward to hearing your suggestions.</p>