AVPlayer not working with AirPlay
Asked Answered
V

1

7

I have a sequence of AVMutableCompositions that I am playing with AVPlayer. Everything works great when I am playing via speaker, headphones, or bluetooth. However, as soon as I connect to AirPlay, everything falls apart.

I can play one asset, and I try to switch to a new asset, I get an AVAudioSessionMediaServicesWereResetNotification and the device disconnects from AirPlay. I tried exporting the AVMutableCompositions to files and then using AVURLAssets, but this didn't seem to change anything.

Does anyone know what is going on here? It looks like I won't be able to support AirPlay...

I get the feeling that I could switch to AVAudioPlayer and this would fix the problem, but I am generating dozens of AVMutableCompositions and don't want to be reading and writing them to disk.

Vezza answered 29/1, 2015 at 4:33 Comment(0)
T
11

This is counter-intuitive, but try setting

myPlayer.allowsExternalPlayback = NO;

The documentation is not completely clear on this, but it seems that this will disallow video playback only. When I do this in my app (which uses AVPlayer), Airplay with an AVComposition works. Even the artwork shows up nicely (via an MPNowPlayingInfoCenter).

Tannin answered 29/3, 2015 at 1:54 Comment(2)
you're right. It disables video only, the sound stills play on the Apple TVMilli
I can also confirm it allows audio but disables video. How can you make it so that also video will get through?Impromptu

© 2022 - 2024 — McMap. All rights reserved.