PIP 모드 (Picture-in-Picture) 정보
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
PIP (Picture-in-Picture)는 주로 동영상 재생에 사용되는 특수한 유형의 멀티 윈도우 모드입니다. 사용자가 기본 화면에서 앱 간에 이동하거나 콘텐츠를 탐색할 때 화면 모서리에 고정된 작은 창에서 동영상을 볼 수 있습니다.
PIP는 Android 7.0에서 사용할 수 있는 멀티 윈도우 API를 활용하여 고정 동영상 오버레이 창을 제공합니다. PIP를 앱에 추가하려면 활동을 등록하고 필요한 경우 활동을 PIP 모드로 전환하며 활동이 PIP 모드일 때 UI 요소를 숨기고 동영상 재생이 지속되게 해야 합니다.
PIP 모드에서 UI 처리
PIP 모드로 전환하면 UI가 PIP 모드와 PIP 모드 외부에서 어떻게 표시되는지 지정하지 않는 한 앱의 전체 UI가 PIP 창으로 전환됩니다.
먼저 앱이 PIP 모드인지 여부를 알아야 합니다. OnPictureInPictureModeChangedProvider
를 사용하여 이 작업을 실행할 수 있습니다.
아래 코드는 앱이 PIP 모드인지 알려줍니다.
@Composable
fun rememberIsInPipMode(): Boolean {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
val activity = LocalContext.current.findActivity()
var pipMode by remember { mutableStateOf(activity.isInPictureInPictureMode) }
DisposableEffect(activity) {
val observer = Consumer<PictureInPictureModeChangedInfo> { info ->
pipMode = info.isInPictureInPictureMode
}
activity.addOnPictureInPictureModeChangedListener(
observer
)
onDispose { activity.removeOnPictureInPictureModeChangedListener(observer) }
}
return pipMode
} else {
return false
}
}
이제 rememberIsInPipMode()
를 사용하여 앱이 PIP 모드로 전환될 때 표시할 UI 요소를 전환할 수 있습니다.
val inPipMode = rememberIsInPipMode()
Column(modifier = modifier) {
// This text will only show up when the app is not in PiP mode
if (!inPipMode) {
Text(
text = "Picture in Picture",
)
}
VideoPlayer()
}
이 페이지에 나와 있는 콘텐츠와 코드 샘플에는 콘텐츠 라이선스에서 설명하는 라이선스가 적용됩니다. 자바 및 OpenJDK는 Oracle 및 Oracle 계열사의 상표 또는 등록 상표입니다.
최종 업데이트: 2025-08-23(UTC)
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["필요한 정보가 없음","missingTheInformationINeed","thumb-down"],["너무 복잡함/단계 수가 너무 많음","tooComplicatedTooManySteps","thumb-down"],["오래됨","outOfDate","thumb-down"],["번역 문제","translationIssue","thumb-down"],["샘플/코드 문제","samplesCodeIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-08-23(UTC)"],[],[],null,["Picture-in-picture (PiP) is a special type of multi-window mode mostly used for\nvideo playback. It lets the user watch a video in a small window pinned to a\ncorner of the screen while navigating between apps or browsing content on the\nmain screen.\n\nPiP leverages the multi-window APIs made available in Android 7.0 to provide the\npinned video overlay window. To add PiP to your app, you need to register your\nactivity, switch your activity to PiP mode as needed, and make sure UI elements\nare hidden and video playback continues when the activity is in PiP mode.\n\nHandle your UI in PiP mode\n\nWhen you enter PiP mode, your app's entire UI enters the PiP window unless you\nspecify how your UI should look in and out of PiP mode.\n\nFirst, you need to know when your app is in PiP mode or not. You can use\n[`OnPictureInPictureModeChangedProvider`](/reference/androidx/core/app/OnPictureInPictureModeChangedProvider) to achieve this.\nThe code below tells you if your app is in PiP mode.\n\n\n```kotlin\n@Composable\nfun rememberIsInPipMode(): Boolean {\n if (Build.VERSION.SDK_INT \u003e= Build.VERSION_CODES.O) {\n val activity = LocalContext.current.findActivity()\n var pipMode by remember { mutableStateOf(activity.isInPictureInPictureMode) }\n DisposableEffect(activity) {\n val observer = Consumer\u003cPictureInPictureModeChangedInfo\u003e { info -\u003e\n pipMode = info.isInPictureInPictureMode\n }\n activity.addOnPictureInPictureModeChangedListener(\n observer\n )\n onDispose { activity.removeOnPictureInPictureModeChangedListener(observer) }\n }\n return pipMode\n } else {\n return false\n }\n}https://github.com/android/snippets/blob/7a0ebbee11495f628cf9d574f6b6069c2867232a/compose/snippets/src/main/java/com/example/compose/snippets/pictureinpicture/PictureInPictureSnippets.kt#L119-L137\n```\n\n\u003cbr /\u003e\n\nNow, you can use `rememberIsInPipMode()` to toggle which UI elements to show\nwhen the app enters PiP mode:\n\n\n```kotlin\nval inPipMode = rememberIsInPipMode()\n\nColumn(modifier = modifier) {\n // This text will only show up when the app is not in PiP mode\n if (!inPipMode) {\n Text(\n text = \"Picture in Picture\",\n )\n }\n VideoPlayer()\n}https://github.com/android/snippets/blob/7a0ebbee11495f628cf9d574f6b6069c2867232a/compose/snippets/src/main/java/com/example/compose/snippets/pictureinpicture/PictureInPictureSnippets.kt#L152-L162\n```\n\n\u003cbr /\u003e"]]