2

我在搞乱 Rdio 的 iOS SDK。我已经在此处概述的“入门”中正确设置了所有内容 ( http://www.rdio.com/developers/docs/libraries/ios/ )。应用程序委托中的轨道键在我启动应用程序后工作和播放。

现在我试图让一个简单的 UIButton 点击​​来播放曲目,但我一辈子都无法让它工作。

我在 ViewController.h 中有这个

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

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

@end

在 ViewController.m

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

}

我真的很感激帮助!

4

1 回答 1

1

我解决了我的问题。我的问题是我没有调用我的 App Delegate 中的初始化程序 initWithConsumerKey...。我也未能正确地将其设置为代表。

所以我的 App Delegate 看起来像这样:

#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;
}

在 ViewController.m 中:

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

}

感觉很傻,一开始没看懂!把它放在这里以防它对任何人有帮助。

于 2015-02-02T22:44:49.723 回答