iOS Picture In Picture Button Appearing in the top left of the video player

DEVELOPING APPS NATIVELY PAYS OFF GREATLY

Enabling the Fancy iOS Picture In Picture Video Player on Xamarin

Apple has simplified PIP implementation in iOS 14

Implementation

  1. Add the snippet below to your AppDelegate FinishedLaunching() above your return statement. Make sure that you use the right AVAudioSessionCategory because the PIP controller disappears depending on the category:
var audioSession = AVAudioSession.SharedInstance();
NSError nSError = new NSError();
audioSession.SetCategory(AVAudioSessionCategory.Playback);
audioSession.SetActive(true, AVAudioSessionSetActiveOptions.NotifyOthersOnDeactivation, out nSError);
Info.plist PIP Background mode selected
Entering the PIP view automatically creates a screen with this message
Swiping the video to the right hides the video

Behavior

  1. If the video is playing in the app, you just need to press the home button and it will start. You do not need to tap on the PIP button.
  2. Once playing in the background, you can simply hide the video temporarily by swiping it to the right and it will show an arrow on the screen
  3. There’s only a few default places on the screen you can pin the video to keep playing from which you can’t change.
  4. You can also launch PIP within the app by tapping the PIP icon on the top left of the video controls that automatically is displayed by iOS.
  5. This works since we are using a non-customized AVPlayer for our video, so it may not work with other video libraries.
  6. Video calls with PIP use private API, only available for FaceTime.

--

--

Developers building things, on here to share knowledge. Featured blog for PlanetXamarin.com github.com/saamerm linkedin.com/in/saamer

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store