Search code examples
iphonexcodempmusicplayercontrolleridle-timer

setIdleTimerDisabled and MPMusicPlayer Issue


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?


Solution

  • 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!