Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to keep Airplay running if the device auto-sleeps/auto-locks?

When streaming a video from an iPhone (or any iOS device) to a TV via Airplay, the stream stops as soon as the device goes to sleep from inactivity. At the moment, I disabled the sleep timer so that the device does not automatically sleep, but is there a better solution to this?

Is setting AVPlayer.externalPlaybackActive enough to allow the OS to know to keep playing when the screen is off? If not, is there an alternate way to keep Airplay running even if the device turns off its screen?

like image 422
aeonsamurai Avatar asked Nov 03 '12 07:11

aeonsamurai


People also ask

How do I keep AirPlay from going to sleep?

We recommend you prevent your Apple TV from starting the screensaver or going to sleep when using it for a presentation. To do this, on the Apple TV navigate to Settings > General > Screensaver > Start After > and change it to Never, then go to Settings > General > Sleep After > and change it to Never.

How do I stop my iPhone from locking with AirPlay?

Keep AirPlay Source Device Unlocked In certain cases, AirPlay will stop video playback on a locked device. I've found that AirPlay is much more reliable when the source device (iPhone, iPad, iPod touch) is left unlocked. Go to Settings > General > Auto-Lock and change it to Never.

Why does Apple AirPlay keep turning off?

Airplay disconnecting has become a common issue for many users. This is mostly because too many devices are on the same network. Remove some devices that are not in use from the network to eliminate this problem.


1 Answers

To continue airplay playback, add "App plays audio" to the "Required background modes" in the AppName-info.plist

AppName-info.plist

and set the audio session like:

    [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil];
[[AVAudioSession sharedInstance] setActive: YES error: nil];
like image 172
YoonHo Avatar answered Oct 02 '22 00:10

YoonHo