作者:天佑千行 | 来源:互联网 | 2023-09-24 12:19
ImhavingissuesgettingtheplayandpausebuttonstoggleintheMPRemoteCommandCenter.Forwhatev
I'm having issues getting the play and pause buttons toggle in the MPRemoteCommandCenter. For whatever reason the audio and events will all work correctly, but the command center doesn't change the play button to the pause button. Here's my code...
我在MPRemoteCommandCenter中获取播放和暂停按钮切换时遇到问题。无论出于何种原因,音频和事件都将正常工作,但命令中心不会将播放按钮更改为暂停按钮。这是我的代码......
- (void)setupMPRemoteCommandCenter{
MPRemoteCommandCenter *commandCenter = [MPRemoteCommandCenter sharedCommandCenter];
MPRemoteCommand *play = [commandCenter playCommand];
[play setEnabled:YES];
[play addTarget:self action:@selector(playAudio:)];
MPRemoteCommand *pause = [commandCenter pauseCommand];
[pause setEnabled:YES];
[pause addTarget:self action:@selector(playAudio:)];
[commandCenter.skipBackwardCommand setPreferredIntervals:@[@30.0]];
MPRemoteCommand *skipBackwards = [commandCenter skipBackwardCommand];
[skipBackwards setEnabled:YES];
[skipBackwards addTarget:self action:@selector(skipBackwardEvent:)];
[commandCenter.skipForwardCommand setPreferredIntervals:@[@30.0]];
MPRemoteCommand *skipForwards = [commandCenter skipForwardCommand];
[skipForwards setEnabled:YES];
[skipForwards addTarget:self action:@selector(skipForwardEvent:)];
}
-(void)playAudio: (MPRemoteCommandHandlerStatus *)event{
[self playAction];
//playAction handles the audio pausing and toggling the play button on the app
}
![This is the issue, the media center should show a pause button like the app rather than a play button.](https://img1.php1.cn/3cd4a/24d65/42f/71751f80bc7d7c08.jpeg)
Let me know if you guys can think of anything, I'd love the help. This has been driving me nuts
让我知道,如果你们能想到任何事情,我会很乐意帮助。这让我疯了
1 个解决方案