ios – MPRemoteCommandCenter暂停播放按钮没有切换?

ios – MPRemoteCommandCenter暂停播放按钮没有切换?,第1张

概述我在MPRemoteCommandCenter中获取播放和暂停按钮切换时遇到问题.无论出于何种原因,音频和事件都将正常工作,但命令中心不会将播放按钮更改为暂停按钮.这是我的代码…… - (void)setupMPRemoteCommandCenter{ MPRemoteCommandCenter *commandCenter = [MPRemoteCommandCenter sharedC 我在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}

让我知道,如果你们能想到任何事情,我会很乐意帮助.这让我疯了

解决方法 关于我如何解决这个问题的一些指示.
阅读苹果 documentation它说“你的应用程序必须是”正在播放“应用程序.应用程序在开始播放音频之前不会收到远程控制事件”

所以先开始播放音频.

MPRemoteCommandCenter是一个相当自我依赖的模块. setEnabled用于明确表示不支持某些内容.在事件期间不要将它用作切换,AVFoundation将自己处理.

还要注意我在模拟器中切换问题,它在设备上切换很好,但在模拟器中没有切换,这需要花费16个小时才能搞清楚:)

总结

以上是内存溢出为你收集整理的ios – MPRemoteCommandCenter暂停/播放按钮没有切换?全部内容,希望文章能够帮你解决ios – MPRemoteCommandCenter暂停/播放按钮没有切换?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1108125.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-29
下一篇 2022-05-29

发表评论

登录后才能评论

评论列表(0条)

保存