# Picture-in-Picture
ByteArk Player SDK for iOS supports Picture-in-Picture (PiP) so viewers can keep watching in a small floating window while using other apps.
# Background mode setup
To use PiP, enable Background Mode "Audio, AirPlay, and Picture in Picture" in your Xcode project's Capabilities.
# Control PiP via API
// Toggle PiP
player.togglePictureInPictureMode()
// Enable PiP
player.enablePictureInPicture()
// Disable PiP
player.disablePictureInPicture()
// Check state
if player.isInPictureInPicture {
// In PiP mode
}
1
2
3
4
5
6
7
8
9
10
11
12
13
2
3
4
5
6
7
8
9
10
11
12
13
# Receive PiP events
override func playerEnterPictureInPictureMode(player: ByteArkPlayer) {
super.playerEnterPictureInPictureMode(player: player)
// Entered PiP
}
override func playerExitPictureInPictureMode(player: ByteArkPlayer) {
super.playerExitPictureInPictureMode(player: player)
// Exited PiP
}
1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9