# Picture-in-Picture

ByteArk Player SDK for Android supports Picture-in-Picture (PiP) so viewers can keep watching in a floating window while using other apps.

# Activity setup

Configure your activity in AndroidManifest.xml:

<activity
  android:name=".YourActivity"
  android:supportsPictureInPicture="true"
  android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation"
  ...>
</activity>
1
2
3
4
5
6

Then enable PiP in the player builder:

val playerBuilder = ByteArkPlayerBuilder.Builder()
  .withContext(this)
  .withPictureInPicture()
  .build()
1
2
3
4

# Control PiP via API

mPlayerFragment.togglePictureInPicture()
if (mPlayerFragment.isInPictureInPicture()) {
  // In PiP mode
}
1
2
3
4
5

# Receive PiP events

override fun onPipModeEnter() {
  // Entered PiP
}
override fun onPipModeExit() {
  // Exited PiP
}
1
2
3
4
5
6
7