spotify / android-sdk

Spotify SDK for Android
https://developer.spotify.com/documentation/android/
Apache License 2.0
462 stars 119 forks source link

How to clear queue? #31

Open redphx opened 6 years ago

redphx commented 6 years ago

I'm finding a way to clear all songs from queue but couldn't find it. Can we have this feature in the future? Thank you.

alete89 commented 5 years ago

Please this is annoying

arirawr commented 5 years ago

Thanks for the suggestion! We'll post here if there are any updates.

heyjamesknight commented 4 years ago

Any progress here? It's super difficult to develop anything involving queuing without this.

jarjarfinks commented 4 years ago

Same, developing with queue is impossible without this feature. Are there any plans to make this happen soon?

marzuagacds commented 4 years ago

Hi there! :) Any progress on this?

nelson-t commented 4 years ago

Not the best way, but what I do is send a specific track (can be a sound effect) to the queue and keep advancing (and removing items) as fast as possible to the "next" track until I find the "id" (the end of the playing queue). Here is the Js code of my recursive function. It can give you a rough idea of a possible solution:

static clearSpotifyQueue(init) { //Recursive
      let i=init;
      let id="0ICWP0NnWaJUCgp6EvgNmT"; //Mission Imposible, my 'tag' track. This can also be changed so that you can send an specific id to the function.
      let tId="";
      if(i>=25){setLoops(); return;} //Max number of tracks in the queue that will be removed
      if(i===0){  //the first time send the track to the queue
         clearInterval(theLoop);  //specific to my application. Stops updating the UI
         $.ajax({
            url: 'https://api.spotify.com/v1/me/player/queue?uri=spotify:track:'+id , method:'POST', 
            headers: Player.getHeaders()  //replace by corresponding headers
         }).done(setTimeout(function(){Queue.clearSpotifyQueue(i+1);},1000)); //adds some delay before calling the function again, otherwise it won't work
      } else {  
         $.ajax({ 
            url: 'https://api.spotify.com/v1/me/player', method: 'GET', headers: Player.getHeaders()
         }).done(function (data) {
            tId = data.item.id;
            if(tId===id) {
               Player.next(0);  //implements a simple player/next or eliminate if you want to play the 'tag' track 
               setLoops(); //specific to my application...change it.
            } else {
               $.ajax({
                  url: 'https://api.spotify.com/v1/me/player/next', method:'POST', headers: Player.getHeaders()  
               }).done(setTimeout(function(){Queue.clearSpotifyQueue(i+1);},2000));
            }
         });
      }
egomezsumma commented 4 years ago

Yes i gonna do the same, enqueue a specify song (hope user does not enqueue that song before). I think the api (web and sdk) are very limited.

mixeden commented 2 years ago

Dudes?

PolygonFox commented 2 years ago

The current state of the API gives very limited control of the playback.

I want to hold and control a playlist in my application and keep the playback in sync. I tried 2 different methods to achieve this:

I would love to hear suggestions/work arounds :)

alexlwn123 commented 1 year ago

5 years later... please add support for this or at least explain why you won't

StuxVT commented 1 year ago

Spotify please we're starving over here

egomezsumma commented 1 year ago

So simple of implement, but they dont care about us :P