我正在研究 Rdio 的 iOS SDK。我已经在此处概述的“入门”中正确设置了所有内容 (http://www.rdio.com/developers/docs/libraries/ios/)。应用程序委托(delegate)中的轨道键在我启动应用程序后起作用并播放。
现在我正在尝试让一个简单的 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];
}
非常感谢您的帮助!
最佳答案
我解决了我的问题。我的问题是我没有调用我的 App Delegate 中的初始化程序 initWithConsumerKey...。我也未能将其正确设置为委托(delegate)。
所以我的 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"];
}
感觉很傻,我一开始没明白!把它留在这里以防它对任何人有帮助。
关于ios - 无法让 Rdio iOS SDK 播放正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28248822/