Can't get Rdio iOS SDK playback to work

41 views
Skip to first unread message

May Yang

unread,
Jan 31, 2015, 1:23:22 AM1/31/15
to rdio...@googlegroups.com
Can't get basic playback to work -- apologies for noob question.


So far I have set everything up in "Getting Started" correctly (http://www.rdio.com/developers/docs/libraries/ios/).  The track key in the app delegate works and plays after I launch the app.

Now I'm trying to get a simple UIButton click to play a track, and I can't for the life of me get it to work. 

I have this in ViewController.h

#import <UIKit/UIKit.h>
#import <Rdio/Rdio.h>

@interface ViewController : UIViewController <RdioDelegate, RDPlayerDelegate>
@property (readonly) Rdio *rdio;

@end
And in ViewController.m
- (IBAction)playButton:(UIButton *)sender
{
    [self.rdio preparePlayerWithDelegate:nil];
    NSArray *sources = [NSArray arrayWithObjects:@"t1", @"p1", @"a1", nil];
    [self.rdio.player playSources:sources];

}

Really appreciate the help.

R. Kevin Nelson

unread,
Feb 2, 2015, 10:31:01 AM2/2/15
to rdio...@googlegroups.com
Hi May,

Is the RDPlayerDelegate calling back the `rdioPlayerFailedDuringTrack:withError:` method?

I suspect that the issue here is that 't1' doesn't actually resolve to a streamable track in your region, which is causing playback to fail.

Also, you should only be preparing the player once, rather than every time the play button is tapped.  Most likely, you want that call to be in the `viewDidLoad` method of your view controller.

Based on the code you've provided, you'll also need to set the delegates for the rdio object and for the player.  Something like:

    [self.rdio setDelegate:self];
    [self.rdio preparePlayerWithDelegate:self];


If you'd like to test with another track, album, or playlist, you can use the Rdio API Console at http://rdioconsole.appspot.com/ to search for items, or resolve URLs into item keys.  (See the `getObjectForURL` method in the dropdown)


Let us know if you're still running into issues!

Best,
Kevin



-- -- --
R. Kevin Nelson
Auxiliary Berliner
Rdio, Inc.

--
You received this message because you are subscribed to the Google Groups "Rdio API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rdio-api+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rdio-api/30c519ed-2a4b-42c9-bdad-4f071b761764%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

May Yang

unread,
Feb 2, 2015, 4:40:32 PM2/2/15
to rdio...@googlegroups.com
Hey Kevin,

Really appreciate the reply... I actually did get it to end up working.  I think the problem was because I wasn't calling the first instance of initWithConsumerKey... I had it in my App Delegate but wasn't calling it on the play button.  It works now :)

My struggle now is trying to call the API to get the artist name and song to show up on UILabels.  Is there some simple sample code you could reference me?  I've looked at both the Hello and RdioQuiz example but can't seem to replicate it :(.

Cheers!

R. Kevin Nelson

unread,
Feb 9, 2015, 7:46:12 AM2/9/15
to rdio...@googlegroups.com
Hi May,

Sorry for my delayed reply.

I'm not sure if I'm understanding you correctly, but it sounds like you're calling `initWithConsumerKey` multiple times from within the same app, which is probably not the best idea.  You should be calling that method once on app launch, and then saving the reference to the Rdio object in a way that's accessible to the rest of your app (perhaps via a Manager object, or via a method on the shared appDelegate).

As for getting the track info onto the labels, are you able to change the labels to some kind of mocked text in response to tapping the play button, or in response to listening to changes in playback state?

On the other side of things, are you able to print out a log message of the track name when the track starts playing?

The `hello-ios-playback` project does this in the following places:


Hope this helps, and let us know if you have any other questions.


Best regards,

Kevin




-- -- --
R. Kevin Nelson
Auxiliary Berliner
Rdio, Inc.

Reply all
Reply to author
Forward
0 new messages