Apple Event: May 7th at 7 am PT

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

AirPlay stops working when iPad screen blanks

I found that after upgrading my iPad 2 to iOS 5 and Apple TV to iOS 4.4 AirPlay video no longer continues in the background. When I move away from the iPad 2 app that is steaming to the TV or the iPad 2 locks itself (screen blanks), the Apple TV stops playing the video. This worked fine before the iOS updates.

AppleTV 2, iOS 5

Posted on Oct 23, 2011 12:55 AM

Reply
33 replies

Nov 23, 2011 6:43 AM in response to RichieBBB

Just re-checked my Apple TV firmware, and found it's back to 4.4.3 and the issue is happening again!

I'm quite sure just a few hours ago the Apple TV firmware saids 5.0.1(9443), and it fixes the issues in this thread!

This is weired.


Good thing is that it's quite promising next Apple TV firmware update will fix this bug, however, the bad thing - is Apple able to upgrade/downgrade or send patches to our system without any notification?

Dec 13, 2011 7:10 PM in response to RichieBBB

I just bought an Apple TV 2. When using Airplay with my iPad 2, the iPad locks after 2 minutes (as I set it) even if I m playing a movie on my TV using Airplay. Two way to fix this:

1) set your iPad Auto Lock to "never". This will likley deplete your iPad battery.

2) hook your iPad to a power supply !


No problem since I used the second option.

Feb 3, 2012 10:45 AM in response to RichieBBB

This issue is that starting with iOS 5, apps are put to the background when the device goes to sleep (even if your app was the forground app!!!).


So the solution is to configure your app as one that can play audio in the background (works for video too).


First you must add this to your info.plist:

User uploaded file


Here is a very simple view controller that works with AirPlay when your app is put to sleep:


BMTViewController.h:

#import <UIKit/UIKit.h>

#import <AVFoundation/AVFoundation.h>

#import <MediaPlayer/MediaPlayer.h>


@interface BMTViewController : MPMoviePlayerViewController

{

}


@end



BMTViewController.m:

#import "BMTViewController.h"


@implementation BMTViewController


#pragma mark - View lifecycle


- (void)viewDidLoad

{

[superviewDidLoad];


self.moviePlayer.allowsAirPlay = YES;

[[AVAudioSessionsharedInstance] setCategory:AVAudioSessionCategoryPlaybackerror:nil];

[[AVAudioSessionsharedInstance] setActive: YESerror: nil];

[self.moviePlayerprepareToPlay];

}


- (void)viewDidAppear:(BOOL)animated {

[super viewDidAppear:animated];

[[UIApplicationsharedApplication] beginReceivingRemoteControlEvents];

[selfbecomeFirstResponder];

}


- (void)viewWillDisappear:(BOOL)animated {

[super viewWillDisappear:animated];

//End recieving events

[[UIApplicationsharedApplication] endReceivingRemoteControlEvents];

[selfresignFirstResponder];

}


- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation

{


returnYES;

}


//Make sure we can recieve remote control events

- (BOOL)canBecomeFirstResponder {

returnYES;

}


- (void)remoteControlReceivedWithEvent:(UIEvent *)event {

//if it is a remote control event handle it correctly

if (event.type == UIEventTypeRemoteControl) {

if (event.subtype == UIEventSubtypeRemoteControlPlay) {

[self.moviePlayer play];

} elseif (event.subtype == UIEventSubtypeRemoteControlPause) {

[self.moviePlayer pause];

} elseif (event.subtype == UIEventSubtypeRemoteControlTogglePlayPause) {


if(self.moviePlayer.playbackState == MPMoviePlaybackStatePlaying)

[self.moviePlayerplay];


else

[self.moviePlayerpause];

}

}

}


@end



Then just instantiate your view controller from your app delegate or however you like. Here's how I'm doing it in this demo app:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

{

self.window = [[UIWindowalloc] initWithFrame:[[UIScreenmainScreen] bounds]];

// Override point for customization after application launch.



NSURL* movieURL = [NSURLURLWithString:@"http://www.yourmovieurl"];



self.viewController = [[BMTViewControlleralloc] initWithContentURL:movieURL];




self.window.rootViewController = self.viewController;

[self.windowmakeKeyAndVisible];

returnYES;

}





Hope this helps everyone struggling with this issue. There is still one issue that many of you may encounter. NSTimers are suspended when the device goes to sleep, even though the movie is still playing in AirPlay. It isn't the end of the world, but I track progress of movie playback and report it back to a server periodically and I'm unable to accomplish this task with the NSTimers suspended.....sigh.


Craig

May 7, 2012 10:52 AM in response to RichieBBB

Hmm new iOS update 5.1.1 just came out today, which addresses bugs with AirPlay. So maybe Apple fixed it??


"Fixes bugs that affected AirPlay video playback in some circumstances"

http://www.macrumors.com/2012/05/07/apple-releases-ios-5-1-1-with-hdr-airplay-an d-safari-syncing-bug-fixes/


I'll be able to check later tonight and test it out with my AppleTV. Unless someone can give it a try sooner.

AirPlay stops working when iPad screen blanks

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.