One Logo Pool Ball
wwwwwwwwwwwwwwwwwww

Picture in Picture

Float any view in the system picture in picture window on iOS and Android

One.UI.PictureInPicture on Android: a live scoreboard floating over the home screen

One.UI.PictureInPicture floats its children in the system picture in picture window, where they keep updating while the app is in the background.

Usage

Turn it on in the app manifest. Prebuild adds the iOS audio background mode and the Android supportsPictureInPicture activity flag.

one({ native: { app: { pictureInPicture: true } } })

Then wrap the content. Give it a size; the window takes its aspect ratio.

import { useState } from 'react'
import { One } from 'one'
export function LiveScore() {
const [active, setActive] = useState(false)
return (
<One.UI.PictureInPicture
style={{ width: '100%', aspectRatio: 16 / 9 }}
active={active}
autoEnter
onActiveChange={setActive}
>
<Scoreboard />
</One.UI.PictureInPicture>
)
}

API reference

PictureInPicture also accepts React Native ViewProps.

PropsTypeDescription
childrenReactNodeThe content shown inline and in the window.
ReactNodeThe content shown inline and in the window.
activeboolean = falseAsks for the window. Acted on when it changes.
boolean = falseAsks for the window. Acted on when it changes.
autoEnterboolean = falseEnters the window when the app goes to the background.
boolean = falseEnters the window when the app goes to the background.
onActiveChange(active: boolean) => voidEvery real transition, including the system closing the window or the app returning.
(active: boolean) => voidEvery real transition, including the system closing the window or the app returning.

Behavior

iOSAndroidWeb
Window contentChildren redrawn about 30 times a secondThe activity, filled with the childrenInline only
Aspect ratioThe component’sThe component’s, within 1:2.39 to 2.39:1
SimulatoriPad onlyYes

On iOS, the children render into an AVSampleBufferDisplayLayer, so content drawn outside Core Animation, such as video players and Metal or WebGPU canvases, shows its last snapshot. The audio session is set to playback, mixing with other audio.

On Android, the whole activity shrinks into the window. The component freezes the layout at full size and fills the window with just its children, scaled to fit.

Edit this page on GitHub.