How to prevent screensaver stopping AVPlayerViewController audio?

I have written a swift based app for tvos that streams music from the Internet. I use the AVPlayerViewController to do this. The issue is that as soon as the screensaver starts the music stream cuts out, instead of playing in the background.


Can anyone suggest how to allow the audio stream to continue while the screen saver is running?

Accepted Reply

A bit of research suggests the following:

In the info.plist add:

  • "Required background modes", with children of the following values:
    • "App plays audio or streams audio/video using AirPlay"
    • "App downloads content from the network"
  • "Application does not run in background" with value "NO"


This seems to be enough for things to work, though you will need to pay attention to anything that is not background friendly, such as observers.


Note: at this point I have only tested this in the simulator, so I will need to validate this on actual Apple TV when I have access to it.

Replies

If you find a solution can you please tell Apple what it is. Playing an audiobook from a Home Sharing library suffers the same fate. It's the sole reason my daughter still has a 3rd generation Apple TV in her room.

A bit of research suggests the following:

In the info.plist add:

  • "Required background modes", with children of the following values:
    • "App plays audio or streams audio/video using AirPlay"
    • "App downloads content from the network"
  • "Application does not run in background" with value "NO"


This seems to be enough for things to work, though you will need to pay attention to anything that is not background friendly, such as observers.


Note: at this point I have only tested this in the simulator, so I will need to validate this on actual Apple TV when I have access to it.

Is this the correct solution?!