setIdleTimerDisabled 和 MPMusicPlayer 问题
好的,我想禁用我的应用程序中的空闲计时器。我将下面的代码放在 applicationDidFinishLaunching 方法的 appdelegate 中,它工作正常(设备保持解锁状态)
[application setIdleTimerDisabled:YES];
但是,当我通过 MPMusicPlayer 方法播放音乐时,空闲计时器似乎再次启用......很快设备就进入了状态变暗模式,不久之后,“锁定”模式。
我尝试在google上寻找其他方法,但最终没有一个有效。我还尝试将上述代码放入另一个函数中,并在播放音乐时使用 NSTimer 每秒调用该函数,但无济于事。它就是行不通。
我该如何解决这个问题?
Ok I want to disable the idletimer in my app. I put the code below in appdelegate in the applicationDidFinishLaunching method, and it works fine (the device remains unlocked)
[application setIdleTimerDisabled:YES];
Though, when I play a music through MPMusicPlayer methods, the idletimer seems to be enabled back again... and soon the device goes into dimmed mode and soon after, "locked" mode.
I tried to find in google for other methods, but ultimately there are NONE that are effective. I also tried putting the above code in another function and calling that function every seconds using NSTimer when the music is playing, but to no avail. It just won't work.
How can I solve this issue?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
啊。我讨厌回答自己的问题。但你看,答案就在这里:
如何阻止 MPMusicPlayerController 启用屏幕锁定
查看来自的回复亨宁。效果就像一个魅力!
Ugh. I hate answering my own questions. But here you go, the answer is here:
How to stop MPMusicPlayerController from enabling screen locking
See the reply from henning. Works like a charm!