Now Playing 카드 표시
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
오디오를 재생하는 TV 앱은 사용자가 홈 화면으로 돌아간 후에도 계속 재생할 수 있습니다.
다른 앱으로 전환할 수 있습니다. 이렇게 하려면 앱에서 홈에 Now Playing 카드를 제공해야 합니다.
화면 이 카드를 통해 사용자는 오디오 출처를 이해하고 앱으로 돌아가
제어할 수 있습니다.
활성 상태인
MediaSession
:
Android 프레임워크가 홈 화면에 Now Playing 카드를 표시합니다. 카드
앨범 아트, 제목, 앱 아이콘과 같은 미디어 메타데이터가 포함됩니다. 사용자가 카드를 선택하면
시스템에서 앱을 엽니다.
Now Playing 카드
미디어 세션을 구현한 후에는
세션을 활성화하고 오디오 포커스를 요청하면 Now Playing 카드가 표시됩니다.
참고: Now Playing 카드는 미디어 재생에만 표시됩니다.
세션을
FLAG_HANDLES_TRANSPORT_CONTROLS
플래그가 설정되었습니다. 이 플래그는 API 수준 26에서 지원 중단됩니다. 그러나 이전 기기의 경우 이전 버전과의 호환성을 위해 이 플래그가 필요할 수 있습니다.
이 카드는
setActive(false)
호출이 미디어 세션을 비활성화하거나 다른 앱이 미디어 재생을 시작할 때 발생합니다. 재생 상태
완전히 중지되고 활성 미디어가 없으면 미디어 세션을 비활성화합니다.
즉시 삭제할 수 있습니다 재생이 일시중지되면 지연 시간 후 미디어 세션을 비활성화합니다.
보통 5분에서 30분 정도 걸립니다.
카드 업데이트
앱이 MediaSession
에서 재생 상태를 업데이트할 때마다
Now Playing 카드가 업데이트되어 현재 미디어의 상태가 표시됩니다. 자세한 내용은
재생 상태 업데이트
마찬가지로 앱에서
MediaMetadata
제공
현재 미디어에 대한 정보를 Now Playing 카드에 추가합니다.
여러 아이콘이 있습니다. 자세한 내용은
미디어 메타데이터를 업데이트합니다.
사용자 작업에 반응
사용자가 Now Playing 카드를 선택하면 시스템에서
세션입니다. 앱이
PendingIntent
부터
setSessionActivity()
,
시스템은 다음 코드 스니펫과 같이 개발자가 지정한 활동을 시작합니다. 그렇지 않은 경우
기본 시스템 인텐트가 열립니다. 지정한 활동은
사용자가 재생을 일시중지하거나 중지할 수 있게 하세요.
Kotlin
val pi: PendingIntent = Intent(context, MyActivity::class.java).let { intent ->
PendingIntent.getActivity(
context, 99 /*request code*/,
intent,
PendingIntent.FLAG_UPDATE_CURRENT
)
}
session.setSessionActivity(pi)
자바
Intent intent = new Intent(context, MyActivity.class);
PendingIntent pi = PendingIntent.getActivity(context, 99 /*request code*/,
intent, PendingIntent.FLAG_UPDATE_CURRENT);
session.setSessionActivity(pi);
허용되는 사용 사례
Now Playing 카드는 사용자가 오디오가 계속되기를 바라는 경우에만 사용해야 합니다.
앱에서 나갈 때 백그라운드에서 재생되는 것을 볼 수 있습니다. 게임에서 재생되는 동영상 또는 사운드가 항상
일시중지할 수 있습니다.
이 페이지에 나와 있는 콘텐츠와 코드 샘플에는 콘텐츠 라이선스에서 설명하는 라이선스가 적용됩니다. 자바 및 OpenJDK는 Oracle 및 Oracle 계열사의 상표 또는 등록 상표입니다.
최종 업데이트: 2025-07-27(UTC)
[null,null,["최종 업데이트: 2025-07-27(UTC)"],[],[],null,["# Display a Now Playing card\n\nTV apps that play audio may continue to do so after the user returns to the home screen or\nswitches to another app. To do so, the app must provide a **Now Playing** card on the home\nscreen. This card lets users understand where the audio is coming from and return to your app to\ncontrol media playback.\n\n\nWhenever an active\n[MediaSession](/reference/android/media/session/MediaSession) is\npresent, the Android framework displays a **Now Playing** card on the home screen. The card\nincludes media metadata such as album art, title, and app icon. When the user selects the card,\nthe system opens the app.\n\nNow Playing card\n----------------\n\n\nAfter you [implement a media session](/training/tv/playback/media-session), set the\nsession to active, and request audio focus, the **Now Playing** card appears.\n\n**Note:** The **Now Playing** card displays only for a media\nsession with the\n[FLAG_HANDLES_TRANSPORT_CONTROLS](/reference/android/media/session/MediaSession#FLAG_HANDLES_TRANSPORT_CONTROLS)\nflag set. This flag is deprecated on API level 26. However, this flag could still be needed on older devices for backwards compatibility.\n\n\nThe card is removed from the launcher screen when a\n[setActive(false)](/reference/android/media/session/MediaSession#setActive(boolean))\ncall deactivates the media session or when another app initiates media playback. If playback is\ncompletely stopped and there is no active media, deactivate the media session\nimmediately. If playback is paused, deactivate the media session after a delay,\nusually from 5 to 30 minutes.\n\nUpdate the card\n---------------\n\n\nWhenever your app updates the playback state in the `MediaSession`, the\n**Now Playing** card updates to show the state of the current media. To learn how to do this, see\n[Update the playback state](/training/tv/playback/media-session#state).\n\n\nSimilarly, your app can update the\n[MediaMetadata](/reference/android/media/MediaMetadata) to provide\ninformation to the **Now Playing** card about the current media, such as the title, subtitle,\nand various icons. To learn how to do this, see\n[Update the media metadata](/training/tv/playback/media-session#metadata).\n\nRespond to user action\n----------------------\n\n\nWhen the user selects the **Now Playing** card, the system opens the app that owns the\nsession. If your app provides a\n[PendingIntent](/reference/android/app/PendingIntent) to\n[setSessionActivity()](/reference/android/media/session/MediaSession#setSessionActivity(android.app.PendingIntent)),\nthe system launches the activity you specify, as shown in the following code snippet. If not,\nthe default system intent opens. The activity you specify must provide playback controls that\nlet users pause or stop playback. \n\n### Kotlin\n\n```kotlin\nval pi: PendingIntent = Intent(context, MyActivity::class.java).let { intent -\u003e\n PendingIntent.getActivity(\n context, 99 /*request code*/,\n intent,\n PendingIntent.FLAG_UPDATE_CURRENT\n )\n}\nsession.setSessionActivity(pi)\n```\n\n### Java\n\n```java\nIntent intent = new Intent(context, MyActivity.class);\nPendingIntent pi = PendingIntent.getActivity(context, 99 /*request code*/,\n intent, PendingIntent.FLAG_UPDATE_CURRENT);\nsession.setSessionActivity(pi);\n```\n\nAccepted use cases\n------------------\n\n\nThe **Now Playing** card should only be used in cases where the user expects audio to continue\nplaying in the background when leaving your app. Video playback or sound from a game should always\npause, unless your app is integrating and compliant with picture-in-picture."]]