gpt4 book ai didi

ios - MPMoviePlayerController - 检测按下 Next/Prev 按钮

转载 作者:技术小花猫 更新时间:2023-10-29 10:54:12 26 4
gpt4 key购买 nike

我正在使用 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
}

问题是 remoteControlReceivedWithEvent 方法从未被调用。我读过这不适用于高于 6 的 iOS 版本 - 我正在使用 iOS 7

  • 通知

我尝试使用 MPMoviePlayerPlaybackStateDidChangeNotification 并检查 MPMoviePlaybackStateSeekingForwardMPMoviePlaybackStateSeekingBackward - 不幸的是,这些播放状态是在拖动播放栏时设置的,而不是按下一个/上一个按钮。

有什么想法吗?

最佳答案

抱歉,我不太明白你的问题,但如果你想在控制中心使用你的应用程序的控件,你可以使用:

      // You need cath the singleton
MPRemoteCommandCenter *myRemote = [MPRemoteCommandCenter sharedCommandCenter];
//And add the selector you can fire depends on the button, a couple of examples:
[myRemote.playCommand addTarget:self action:@selector(myPlayMethods)];
[myRemote.nextTrackCommand addTarget:self action:@selector(myNextTrackMethods)];

关于ios - MPMoviePlayerController - 检测按下 Next/Prev 按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25381823/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com