Skip to navigation

Enable Picture-in-Picture

controller.pip drives the Picture-in-Picture (PiP) window on both platforms over the SDK’s own platform channel, so PiP never routes through the engine’s fullscreen path.

if (await controller.pip.isPipAvailable()) {
await controller.pip.togglePip();
}
controller.pip.isPipActive;
controller.pip.enabled = false; // master off switch
controller.pip.autoEnterOnBackground = true; // open PiP on leaving the app
controller.pip.setPipAudioBehavior(mixWithOthers: false);
controller.addEventListener(FastPixPlayerEventTypes.pipChanged, (event) {
final active = (event as FastPixPipChangedEvent).isActive;
});

PiP survives a playlist advance, and captions scale to the window rather than rendering at full-player size inside it. Supply the window’s content with pipBuilder on FastPixPlayer or FastPixVideoSurface. Without one, the SDK uses the built-in fastPixDefaultPipLayout.


Platform setup

Android

Mark the activity as PiP capable and let it handle the configuration changes itself, in android/app/src/main/AndroidManifest.xml:

<activity
android:name=".MainActivity"
android:supportsPictureInPicture="true"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
... >

iOS

PiP keeps playing while the app is in the background, which needs the audio background mode in ios/Runner/Info.plist:

<key>UIBackgroundModes</key>
<array>
<string>audio</string>
</array>

What’s next