2

I'm messing around with Rdio's iOS SDK. I've set up everything correctly in "Getting Started" outlined here (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];

}

I really appreciate the help!

May Yang
  • 523
  • 1
  • 5
  • 18
  • Can you upload sample project for look ? – Jageen Jan 31 '15 at 06:43
  • I download sample from here but could not able to build https://github.com/rdio/hello-ios-playback – Jageen Jan 31 '15 at 06:44
  • @Jageen I put my project over here https://github.com/mayyyang/RdioTest. I am able to get the hello-ios-playback to work but can't get it to work on my own project. – May Yang Jan 31 '15 at 19:55
  • 1
    when i click on start button music start, and then pause and play button works perfectly – Jageen Feb 01 '15 at 06:15
  • @Jageen Thanks... I actually did get it to work as you noticed, I didn't update this post, sorry appreciate your time. – May Yang Feb 01 '15 at 06:49

1 Answers1

1

I resolved my issue. My issue was I wasn't calling the initializer initWithConsumerKey... that I had in my App Delegate. I had also failed to set it as a delegate properly.

So my App Delegate looks like this:

#import "AppDelegate.h"

static AppDelegate *launchedDelegate;

@interface AppDelegate ()

@end

@implementation AppDelegate

+ (Rdio *)rdioInstance
{
    return launchedDelegate.rdio;
}


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    launchedDelegate = self;

    _rdio = [[Rdio alloc] initWithConsumerKey:@"removed" andSecret:@"removed" delegate:nil];
    return YES;
}

and in ViewController.m:

- (IBAction)listenButton:(UIButton *)sender
{
    _rdio = [AppDelegate rdioInstance];
    [self.rdio preparePlayerWithDelegate:nil];
    [self.rdio.player playSource:@"p12691138"];

}

Feeling silly that I didn't get that at first! Leaving it up here in case it helps anybody.

May Yang
  • 523
  • 1
  • 5
  • 18
  • Please tell me from where I can get the playSource that is "p12691138" in your code. I need this. – Ashish Tiwari Feb 03 '15 at 09:40
  • I get the track key, but songs are playing till 30 seconds only. why is this happening? – Ashish Tiwari Feb 04 '15 at 06:30
  • @AshishTiwari it's because you need to be an Rdio subscriber to be able to listen to the full track. You'd have to offer authentication in the app, or else it just plays 30 seconds. – May Yang Feb 04 '15 at 08:20