Picture in picture button disabled

Hi folks,


I'm developing a live video player and I want to use the new Picture in Picture option. I based the player on an AVPlayerViewController, and set the property allowsPictureInPicturePlayback to true.


The weird thing is that it works perfectly on the iPad Air 2 simulator, but in the real device the PiP button stays disabled although visible, and the user can't click on it. I though it was for the iOS 9 beta version, so I upgraded today to the latest GM seed pre-release (build 13A340) and the problem is still there.


Any ideas?


Thank you in advance.

Answered by Supermafete in 55763022

Found it!


Must set the the audio session category after the player initialization:


        do {
            try AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayback)
        }
        catch {
            print("Audio session setCategory failed")
        }
Accepted Answer

Found it!


Must set the the audio session category after the player initialization:


        do {
            try AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayback)
        }
        catch {
            print("Audio session setCategory failed")
        }

Hey,

We had the same issue.


You need to have an active AudioSession, otherwise PiP will not be enable on device.


do{     
     try AVAudioSession.sharedInstance().setActive(true)
     try AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryPlayback)
}
catch{}
Picture in picture button disabled
 
 
Q