I'm loading an mp4 video url to AVPlayer
and showing a video. But I also want to allow the user to be able to lock their phone and keep listening to the audio of the video.
However, when I load an mp3 audio only file... it does work. Is there anyway to do it how I want with the video?
This is what I'm doing:
do {
try AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayback, with: .mixWithOthers)
try AVAudioSession.sharedInstance().setActive(true)
} catch {
print(error)
}
Also, my apps entitlements have Background Modes
enabled and Audio, Airplay, and Picture in Picture
enabled