Adding Songs While in The Background [iOS]

111 views
Skip to first unread message

Rahul kishore

unread,
Jun 8, 2012, 11:22:05 AM6/8/12
to Rdio API
Hey There,
While I've been able to get the currently playing song to continue
playing while the App is in the background by adding the right to key
to my info-plist, the system wide play/pause (when double clicking the
home button and swiping to reveal the left mulittasking menu) do not
change to my app's controls. There's also no clear callbacks to the
app that allow for a new song to be queued up.
Apple's audio session guide is all described by using AVFoundation
and the AVPlayer, but it doesn't appear that RDPlayer is a subclass of
AVPlayer. Is it possible to implement the above two features? Is
there a piece of documentation that I should look at to understand how
to be able to play a new song while still in the background
specifically?


Cheers,
Rahul

Devin Sevilla

unread,
Jun 8, 2012, 5:55:31 PM6/8/12
to rdio...@googlegroups.com
On Fri, Jun 8, 2012 at 8:22 AM, Rahul kishore <rahul....@gmail.com> wrote:
> Apple's audio session guide is all described by using AVFoundation
> and the AVPlayer, but it doesn't appear that RDPlayer is a subclass of
> AVPlayer.

You are correct, at this time RDPlayer does not use AVPlayer of
AVFoundation. It currently uses the Audio Toolbox portion of Core
Audio.

> Is it possible to implement the above two features? Is
> there a piece of documentation that I should look at to understand how
> to be able to play a new song while still in the background
> specifically?

I'll dig in deeper and figure out if this is possible using Audio
Toolbox or if I would need to switch to AVPlayer. Stay tuned.

--
Devin Sevilla
API Engineer, Rdio Inc.

Chintan Patel

unread,
Jun 18, 2012, 2:06:51 PM6/18/12
to rdio...@googlegroups.com
Any update on this? I too need to change the song playing in the background. 

Right now the currently playing song plays in background but the app does not play more songs after the first song ends playback. 

On Saturday, June 9, 2012 3:25:31 AM UTC+5:30, Devin S. wrote:

Andy Soell

unread,
Jun 18, 2012, 2:17:22 PM6/18/12
to rdio...@googlegroups.com
You must have missed the announcement earlier this month about the updated iOS SDK. Much better queue management in this new version. Check out the updated documentation at:

http://developers.rdio.com/media/static/developer/ios/docs/
> --
> You received this message because you are subscribed to the Google Groups "Rdio API" group.
> To view this discussion on the web visit https://groups.google.com/d/msg/rdio-api/-/tcYbRQKnnKAJ.
> To post to this group, send email to rdio...@googlegroups.com.
> To unsubscribe from this group, send email to rdio-api+u...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/rdio-api?hl=en.

Chintan Patel

unread,
Jun 19, 2012, 3:21:42 PM6/19/12
to rdio...@googlegroups.com
Andy,

Thanks for your reply and i am currently playing with the new SDK but unable to implement the feature i want. 

If possible, can you give me a general overview about how would i go about changing the song while the app is in background with the new SDK version? I do have a list of track keys to be played (4) but i want to be able to not only change the track when one track finishes playing but also load new tracks when the queue is about to get empty. 

Right now i am not able to accomplish either. 

Any help will be much appreciated. 
> To post to this group, send email to rdio-api..egroups.com.
> To unsubscribe from this group, send email to rdio-api+unsubscrib...ooglegroups.com.

Andy Soell

unread,
Jun 19, 2012, 3:29:29 PM6/19/12
to rdio...@googlegroups.com
Happy to help. It sounds like our apps are fairly similar… here's what I'm doing in rrrrradio, the app I maintain:

1) When the stream starts, I call the RDPlayer:playSources: method with an array of tracks I want to play.
2) Every minute or so, I check a web site that I maintain that keeps an ongoing list of tracks to play, and I load them into an NSArray.
3) I find the index of the currently playing track in this array, and then call the RDPlayer:updateQueue:withCurrentTrackIndex: method. This is the key. This method basically takes the NSArray of tracks you pass to it and updates its own internal queue with new tracks it finds in that list. The player continues playing whatever it was already playing without any interruption. As you can see from the documentation (http://www.rdio.com/media/static/developer/ios/docs/interface_r_d_player.html#a5dcbc6014bba07ad8f5b6c38ab51e403) it does require you to know the index of the currently playing song. If you don't pass that in properly, you'll see an warning about it in the debug area of Xcode.

If what you're trying to do is *stop* playing the current song and move on to a different one while your app is in the background, your process will be similar. You can use the RDPlayer:updateQueue:withCurrentTrackIndex: method to update the queue so that the song you want to play comes up next, and then call the RDPlayer:next method to advance the player to the next track.

Hope that helps!
> To view this discussion on the web visit https://groups.google.com/d/msg/rdio-api/-/FANaKxIz6EsJ.
> To post to this group, send email to rdio...@googlegroups.com.
> To unsubscribe from this group, send email to rdio-api+u...@googlegroups.com.

Chintan Patel

unread,
Jun 19, 2012, 3:35:58 PM6/19/12
to rdio...@googlegroups.com
Wow! Thanks for the super fast reply. I will give it a try and let you know. 
Reply all
Reply to author
Forward
0 new messages