Jan*_*ski 11 mpmovieplayercontroller mpmovieplayer ios ios8
我正在使用MPMoviePlayerController,我需要检测按下Next/Prev按钮.我尝试了几件事,但似乎都没有.
这是我尝试过的:
-(void) viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
[self becomeFirstResponder];
}
-(void) viewWillDisappear:(BOOL)animated
{
[[UIApplication sharedApplication] endReceivingRemoteControlEvents];
[self resignFirstResponder];
[super viewWillDisappear:animated];
}
-(BOOL)canBecomeFirstResponder
{
return YES;
}
-(void)remoteControlReceivedWithEvent:(UIEvent *)receivedEvent
{
// stuff
}
Run Code Online (Sandbox Code Playgroud)
问题是remoteControlReceivedWithEvent方法永远不会被调用.我已经读过,这在iOS版本高于6时无效 - 我正在iOS 7上工作
我尝试使用MPMoviePlayerPlaybackStateDidChangeNotification并检查MPMoviePlaybackStateSeekingForward或者MPMoviePlaybackStateSeekingBackward- 不幸的是,拖动播放栏时设置了这些播放状态,而不是按下"下一个/上一个"按钮时.
有任何想法吗?
抱歉,我不太了解您的问题,但是如果您想在控制中心使用应用程序的控件,您可以使用:
\n\n // You need cath the singleton\nMPRemoteCommandCenter *myRemote = [MPRemoteCommandCenter sharedCommandCenter];\n//And add the selector you can fire depends on the button, a couple of examples:\n[myRemote.playCommand addTarget:self action:@selector(myPlayMethods)];\n[myRemote.nextTrackCommand addTarget:self action:@selector(myNextTrackMethods)];\nRun Code Online (Sandbox Code Playgroud)\n
| 归档时间: |
|
| 查看次数: |
2283 次 |
| 最近记录: |