
> App正在后台运行音乐或视频(使用MPMovIEPlayerController).
>用户双击主页按钮并转到显示播放控件的第一个屏幕(快退,播放或暂停,快进按钮)
>用户单击快退或快进按钮.
然后应用播放上一个或下一个音乐或视频.
对于第3步,我应该知道单击了哪个按钮.
(我自然知道,当前播放的项目已暂停,停止使用MPMovIEPlayerPlaybackStateDIDChangeNotification通知).
我应该注册哪个通知?还是有其他方法吗?
解决方法 我自己得到了答案.那是使用UIApplication的beginReceivingRemoteControlEvents.
在适当的地方(如vIEwWillAppear :)放入以下代码
[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];[self becomeFirstResponder];
并且视图控制器应该实现以下方法返回YES
- (BOol)canBecomeFirstResponder { return YES; } 然后您可以通过以下方法接收远程控制器事件.
- (voID)remoteControlReceiveDWithEvent:(UIEvent *)event { if( event.type == UIEventTypeRemoteControl ) { NSLog(@"sub type: %d",event.subtype); }} event.subtype如下,
typedef enum { // available in iPhone OS 3.0 UIEventSubtypeNone = 0,// for UIEventTypeMotion,available in iPhone OS 3.0 UIEventSubtypeMotionShake = 1,// for UIEventTypeRemoteControl,available in iPhone OS 4.0 UIEventSubtypeRemoteControlPlay = 100,UIEventSubtypeRemoteControlPause = 101,UIEventSubtypeRemoteControlStop = 102,UIEventSubtypeRemoteControlTogglePlayPause = 103,UIEventSubtypeRemoteControlNextTrack = 104,UIEventSubtypeRemoteControlPrevIoUsTrack = 105,UIEventSubtypeRemoteControlBeginSeekingBackward = 106,UIEventSubtypeRemoteControlEndSeekingBackward = 107,UIEventSubtypeRemoteControlBeginSeekingForward = 108,UIEventSubtypeRemoteControlEndSeekingForward = 109,} UIEventSubtype; 总结 以上是内存溢出为你收集整理的ios – 如何知道用户在iPhone中的播放控件上单击快进和快退按钮全部内容,希望文章能够帮你解决ios – 如何知道用户在iPhone中的播放控件上单击快进和快退按钮所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)