Allow "Auto Lock" While Video Is Being Played

How can I keep a MPMoviePlayerController from dismissing on lock button press?

After toying with a thousand other things I found what I needed to do.

All I needed to do was make two adjustments:

  1. Add this to the AppDelegate.m in the application: didFinishLaunchingWithOptions: method:

    NSError *error = nil;

    BOOL success = [[AVAudioSession sharedInstance]
    setCategory: AVAudioSessionCategoryPlayback
    error: &error];

    if (success == false) { /* handle error */ }
  2. Add the following to your info.plist after you drag it into a text editor like Sublime:

    <key>UIBackgroundModes</key>
    <array>
    <string>audio</string>
    </array>

If you setup your video correctly you will be able to listen to the audio from the video while using other apps and while the screen is in sleep mode.

Autolock iOS device while in camera mode

You're unfortunately not going to be able to do this unless you do a round-about hack assuming the user's device is already set to lock after 1 minute.

If the latter case is true you can disable the idleTimerDisabled and after your period of inactivity re-enable the idleTimer which will then trigger the phone to be able to lock again after 1 minute.

How to disable iPhone/iPad auto-lock while app is in foreground mode?

Enable the idle timer in

- (void)applicationWillResignActive:(UIApplication *)application

and disable it in

- (void)applicationDidBecomeActive:(UIApplication *)application

Prevent automatic screen lock on Windows Phone 8

The screen can be forced to stay on using the UserIdleDetectionMode property of the current PhoneApplicationService.

To disable automatic screen lock:

PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled;

To enable it again:

PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Enabled;

More information can be found on MSDN



Related Topics



Leave a reply



Submit