Skip to content

Comments

Add Pip Support for android and ios#170

Open
dhiaspaner wants to merge 7 commits intokdroidFilter:masterfrom
dhiaspaner:master
Open

Add Pip Support for android and ios#170
dhiaspaner wants to merge 7 commits intokdroidFilter:masterfrom
dhiaspaner:master

Conversation

@dhiaspaner
Copy link

@dhiaspaner dhiaspaner commented Feb 21, 2026

PR: Feature - Picture-in-Picture (PiP) Support

📝 Description

This Pull Request introduces Picture-in-Picture (PiP) mode to the ComposeMediaPlayer library. This feature allows users to continue watching video content in a floating window while navigating away from the application on mobile devices.

📱 Supported Platforms

Platform Status Notes
Android Fully supported using native Android PiP APIs (requires Android 8.0+).
iOS Fully supported using AVPictureInPictureController.
Desktop Not supported (No-op).
Web Not supported (No-op).

🛠 Implementation Details

Common Code

  • Introduced a platform-agnostic interface to handle PiP requests.
  • Added logic to gracefully handle PiP triggers on unsupported platforms (no-op).

Android

  • Enabled android:supportsPictureInPicture="true" in the manifest.
  • Implemented something similar toonUserLeaveHint to automatically enter PiP mode when the user backgrounds the app while video is playing.
  • Configured PictureInPictureParams to handle aspect ratio updates dynamically based on the video content.

iOS

  • Integrated AVPictureInPictureController with the existing AVPlayer layer.
  • Handled the restoration of the user interface when returning from PiP mode.

🧪 How to Test

Android

  1. Launch the app and start playing a video.
  2. Press the Home button or swipe up to go home.
  3. Expectation: The app minimizes into a floating PiP window, and the video continues playing.
  4. Tap the PiP window to expand it back to full screen.

iOS

  1. Launch the app and start playing a video.
  2. Swipe up to go home or tap the PiP toggle button.
  3. Expectation: The video detaches into a floating overlay, and playback continues.
  4. Lock the screen and verify audio continues playing.

📸 Screenshots / Screen Recordings

(Please attach screenshots or a GIF/video of the PiP transition on Android and iOS here)

⚠️ Notes

  • Android: Min SDK is set to 23, but PiP requires API 26+. Checks are in place to ensure safety on older devices.
  • iOS: Requires "Audio, AirPlay, and Picture in Picture" to be enabled in the Background Modes capability.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant