iOS 4 中如何在后台启用 iPod 控件来控制非 iPod 音乐? [英] How to enable iPod controls in the background to control non-iPod music in iOS 4?

查看:13
本文介绍了iOS 4 中如何在后台启用 iPod 控件来控制非 iPod 音乐?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试完成的一个很好的例子是在最新版本的 Spotify iPhone 应用程序中实现(Pandora 似乎具有相同的功能).

A good example of what I'm trying to accomplish is implemented in the latest version of the Spotify iPhone application for (Pandora seems to have the same feature) .

当 Spotify 在后台时,双击打开多任务坞站",其中 ipod 控件(播放/暂停、前进等)允许控制 Spotify 的音乐播放(而不是 ipod 应用程序).此外,当 iphone/ipod touch 锁定时,双击会显示类似的播放控件.

When Spotify is in the background, double tapping opens the "multi-task dock", where the ipod controls (play/pause, forward etc) allow to control the music playback of Spotify (not the ipod application). Also, when the iphone/ipod touch is locked, double tapping displays similar playback controls.

如果你不明白我的意思,这里有一篇有截图的文章:http://www.wired.com/gadgetlab/2010/07/spotify-updated-for-ios4-ready-to-replace-ipod/

If you don't know what I mean, here's an article that has screenshots : http://www.wired.com/gadgetlab/2010/07/spotify-updated-for-ios4-ready-to-replace-ipod/

在我当前的应用程序中,音乐从服务器流式传输(使用 Matt Gallagher 的 AudioStreamer).我设法让音乐在后台播放.现在,我想将我的播放链接到多任务停靠"/锁定屏幕.

In my current application, music is streamed from a server (using Matt Gallagher's AudioStreamer). I've managed to keep the music playing in the background. Now, I'd like to link my playback to the "multi-task dock"/lock screen.

我应该使用 [MPMusicPlayerController iPodMusicPlayer] 吗?我应该怎么做?

Should I be using [MPMusicPlayerController iPodMusicPlayer] ? How should I proceed ?

额外问题:如果您能告诉我如何将 ipod 图标更改为我在多任务坞站"中的应用程序图标(Spotify 也采用了这个技巧......),那就太棒了.

Bonus question : if you can tell me how to change the ipod icon to my application icon in the "multi-task dock" (Spotify pulled that trick as well...), that whould be AWESOME.

任何帮助表示赞赏,谢谢.

Any help appreciated, thanks.

推荐答案

问题解决了.

简而言之,要启用远程控制事件,1)使用:

In short, to enable remote control event, 1) use :

- (void)remoteControlReceivedWithEvent:(UIEvent *)theEvent

和 2) 把它作为你的视图控制器:

and 2) put this is your view controller :

- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
    [[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
    [self becomeFirstResponder];
}
- (BOOL)canBecomeFirstResponder {
    return YES;
}

我必须感谢格兰特.他分叉了 Matt Gallagher 的 AudioStreamer,支持所有 ios4 改进(背景音频和远程控制工作).您可以在 github 上找到他的源代码和工作示例:http://github.com/DigitalDJ/AudioStreamer

I have to give credit to Grant. He has forked Matt Gallagher's AudioStreamer enabling all the ios4 improvements (background audio, and remote controls working). You can find his sources along with a working sample on github : http://github.com/DigitalDJ/AudioStreamer

关于图标:一旦您使用beginReceivingRemoteControlEvents,图标会自动切换到您的应用程序图标.太棒了!

Regarding the icon : once you use beginReceivingRemoteControlEvents, the icon automatically switches to your app icon. Brilliant !

这篇关于iOS 4 中如何在后台启用 iPod 控件来控制非 iPod 音乐?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆