无法使 Rdio iOS SDK 播放正常工作
Can't get Rdio iOS SDK playback to work
我正在研究 Rdio 的 iOS SDK。我已在此处概述的 "Getting Started" (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];
}
非常感谢您的帮助!
我解决了我的问题。我的问题是我没有调用我的 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"];
}
感觉很傻,我一开始没明白!把它留在这里以防它对任何人有帮助。
我正在研究 Rdio 的 iOS SDK。我已在此处概述的 "Getting Started" (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];
}
非常感谢您的帮助!
我解决了我的问题。我的问题是我没有调用我的 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"];
}
感觉很傻,我一开始没明白!把它留在这里以防它对任何人有帮助。