ios - 无法让 Rdio iOS SDK 播放正常工作

标签 ios objective-c xcode rdio

我正在研究 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/

相关文章:

ios - iOS 13 中 UISearchBar 取消按钮的 Xamarin 问题

ios - 在 performSelectorInBackground 中将参数传递给 @selector?

objective-c - 如何在运行时找到 NSUserNotification 的样式?或者强行关闭警报?

ios - 键盘和 UI 元素高度的自动布局问题

ios - 命令因信号 : Segmentation fault:11 而失败

ios - 可调整大小然后可滚动的 UITextView,如 Telegram

iphone - 在 removeFromSuperview 之后调用 addSubview

objective-c - 为什么静态库有一个带有 init 方法的类?

ios - 如何根据背景图像颜色更改 UILabel 文本颜色?

iphone - 我怎样才能从 NSMutableArray 中删除 [NSNull Null] 对象?