ios-sdk icon indicating copy to clipboard operation
ios-sdk copied to clipboard

Suggestion: Enable/Disable AutoPlay

Open anscash opened this issue 5 years ago • 17 comments

Hi guys

My team and I would love to enable / disable for our spotify-using application! Our Android Colleagues also mentioned this feature here: https://github.com/spotify/android-sdk/issues/90

Greetings

anscash avatar Sep 27 '19 14:09 anscash

Any word on this? I would also find it very useful if auto-play after authentication could be disabled.

alake16 avatar Sep 29 '19 04:09 alake16

There was a bug that started playback when authentication was requested. This has been fixed in the latest version of Spotify. An SDK update is not needed.

However that won't let you control Spotify using AppRemote. Spotify on iOS needs to be playing music in order for the SDK to connect to it. So authorizeAndPlayURI will always start playback.

kkarayannis avatar Oct 02 '19 08:10 kkarayannis

@kkarayannis Thanks for your response but i think you misunterstood my question. If i talk about autoplay, i mean the automatic next playback after a track.

Example: I call the play() - method with a specific trackURI. After the track is finished, spotify will start another track, depending on the "radio" of the previous track. I would love to disable this behaviour. So if i "disable" AutoPlay, the playback would be paused after the first track, which i set, finished.

Greetings

anscash avatar Oct 02 '19 09:10 anscash

Ok I understand your question now. There are no plans to enable something like this.

kkarayannis avatar Oct 02 '19 10:10 kkarayannis

No plans ok. But will you accept Pull Requests on this? Best regard.

patrice4github avatar Oct 08 '19 15:10 patrice4github

@patrice4github This would most likely need support from the Spotify app itself so making a change to this SDK wouldn't be enough.

But you can always just pause from your app using the SDK when the track changes. It should accomplish the same goal, right? @anscash

kkarayannis avatar Oct 09 '19 08:10 kkarayannis

Right. I can't get the getPlayerState callback to trigger either (I know there's an open issue about this already). I'll try to get it to fire in the demo app for now.

The Framework source isn't open ain't it. Or is it just me not finding it. Is it for a security reason?

patrice4github avatar Oct 09 '19 12:10 patrice4github

@kkarayannis No it is not solution for us because the delay is too large.. You can listen the first ~ 0.5 second of the track before the pause action is done... :-(

anscash avatar Oct 09 '19 15:10 anscash

No it's not open source. It's for legal reasons but I can't get any more specific than that.

kkarayannis avatar Oct 09 '19 15:10 kkarayannis

Right now, I'm using appRemote as a requested scope with my SPTSessionManger to have access to using the player API from appRemote when I want to play a song on a certain screen in my app. Is there another way I can do this instead of through the appDelegate, so that the music doesn't automatically play when my app establishes connection with the Spotify app initially for authorization?

alake16 avatar Oct 09 '19 15:10 alake16

@alake16 Music needs to be playing for the SDK to connect to the app. That’s an iOS limitation.

kkarayannis avatar Oct 09 '19 16:10 kkarayannis

I can connect to the app just fine. I'm now running the DemoApp on my phone. I have created another button as well that calls playerAPI getPlayerState. I cannot get the callback to fire no matter what I do.

I have committed my new button in a new branch. Pardon my inexperience, I can't seem to be able to create a PR. I'm asked to compare master with my branch (which I'm not authorized to push). Is there anything special I need to do to create a PR?

patrice4github avatar Oct 10 '19 20:10 patrice4github

Pardon the previous noob comment, I have created a proper PR. The Demo app in the branch has a button that call playerAPI getPlayerState, and the callback never fires, whether the music is playing or not.

patrice4github avatar Oct 11 '19 15:10 patrice4github

I have created a PR for this. I have tried everything there's to try, no matter what I do, the getPlayerState callback never triggers on my devices.

Is there any way to debug this? Best regards.

patrice4github avatar Oct 14 '19 22:10 patrice4github

Are there work arounds for this? After a song ends, it triggers the radio. Is there a way to just play 1 track and stop? Repeat: off seems like it should do that, but instead the radio is on?

stephaniegoldman12 avatar Feb 18 '20 03:02 stephaniegoldman12

The only way is for the user to disable the Autoplay option in Settings -> Playback in the Spotify app.

kkarayannis avatar Feb 18 '20 13:02 kkarayannis

Same question / problem here.

Radio / auto-play makes it hard to take total control over playback. Play one song with the SDK and the app will automatically pick and start a radio song right after it.

I am having some luck with a gross hack:

  • play the first song you want and queue a silent track after that
  • get the playerStateChange event and see that its the start of the silent track
  • play the next song you want and queue a silent track after that

As long as you intercept the silent track, auto play / radio doesn't get triggered.

Only other thing I can think of is to use a timer to track the end of the playing track, then pause it and play the next one.

nzoschke avatar Feb 06 '22 20:02 nzoschke