> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://fastpix.com/docs/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://fastpix.com/docs/_mcp/server.

# Enable Picture-in-Picture

> Play FastPix video in a Picture-in-Picture window from the FastPix Flutter Player on Android and iOS, with platform setup and a custom window layout.

`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.

```dart
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`:

```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`:

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

\


## What's next

* [Control video playback](/docs/flutter-player/control-video-playback) for play, pause, seek, and volume.
* [Manage a playlist](/docs/flutter-player/manage-a-playlist) to keep PiP playing across items.