media3-cast-integration
하는 일
이 스킬은 Media3 라이브러리로 Android 앱에 Google Cast 재생을 추가하는 방법을 안내합니다. 의존성, 매니페스트, Cast 옵션, Compose와 View 화면용 플레이어를 다룹니다. Cast 기능을 원하거나 기존 Cast SDK에서 옮기려는 Android 개발자를 위한 스킬입니다.
사용하는 경우
- ✓사용자가 Android 앱에서 동영상이나 오디오를 TV나 스피커로 캐스트하기를 원할 때.
- ✓기존 Google Cast SDK에서 Media3 Cast로 앱을 옮겨야 할 때.
- ✓Compose나 View 앱에 Cast 플레이어와 옵션 제공자를 설정하고 싶을 때.
스킬 링크
https://github.com/android/skills/blob/main/media/media3-cast-integration/SKILL.md복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.
사용 방법
가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
AI에게 요청하는 예시
“사용자가 TV로 캐스트할 수 있도록 Media3를 사용해 내 Android 동영상 앱에 Google Cast를 추가해 주세요.”
매주 새 스킬 5개. 읽는 데 1분.
작동 방식
이 스킬은 Media3 버전이 1.9.0 이상인지 확인한 뒤, 필요한 의존성과 매니페스트 항목을 추가합니다. 그다음 Cast 옵션과 앱 화면용 Cast 플레이어를 설정합니다.
기술 내용 (원본 SKILL.md)
작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.
Prerequisites
- Jetpack Media3 version must be
>= 1.9.0. Cast isn't available in lower versions.
Glossary
CastPlayer: Media3Playerthat controls playback on both local and remote Cast devices.RemoteCastPlayer: Media3Playerthat communicates with a Cast receiver, only used for remote playback.- Google Cast SDK: Legacy casting SDK in maintenance mode, superseded by Jetpack Media3.
OptionsProvider: Interface providing configuration options to initialize GMSCastContext.
Common guidelines
- Legacy Google Cast SDK is in maintenance mode.
- For new Cast setups:
- You must use Jetpack Media3 Cast.
- You mustn't use legacy Cast SDK unless explicitly requested.
Step 1: Set up dependencies
To complete this step, you MUST ensure the following:
In the app-level build file, declare the
media3-castdependency version 1.9.0 or higher.implementation("androidx.media3:media3-cast:1.11.1")Ensure required Media3 dependencies are present:
androidx.media3:media3-exoplayerandroidx.media3:media3-sessionandroidx.media3:media3-ui-compose
If the application uses legacy Views, add
media3-ui.Enforce the same versions across all Media3 dependencies.
Use configurations in "Add build dependencies" section of Getting started with CastPlayer as the source of truth.
For apps without an existing Cast integration:
- Verify legacy Cast SDK (
libs.play.services.cast.framework) is absent.
- Verify legacy Cast SDK (
If Migrating from Legacy Cast SDK:
- Add Media3 Cast dependencies first.
- Keep existing legacy dependencies untouched at this stage to prevent compilation errors.
Step 2: Update the manifest
To complete this step, you MUST ensure the following:
- Inside the manifest's
<application>tag, declare the Cast options provider. - Use
DefaultCastOptionsProviderby default. See the "OptionsProvider" section in Getting started with CastPlayer. - Declare a custom
OptionsProvideronly if explicitly requested. See Customize CastOptions. - Ensure
INTERNETpermission is present. Don't add any unnecessary permissions. - If Migrating from Legacy Cast SDK:
- Don't delete existing custom options provider files or manifest entries.
Step 3: Implement the player and service
Architecture baseline
Before integrating Media3 Cast, an existing app follows one of two setups:
- Local-only playback: Uses Media3
ExoPlayeronly to support local playback. - Legacy Cast setup: Uses
ExoPlayerfor local playback, alongside aPlayerwrapper over the legacyRemoteMediaClientfor remote playback. The UI interfaces with aMediaSessioninteracting with aForwardingPlayer, which finally routes controls to either local or remote playback.
To complete this step, you MUST ensure the following:
- Inside the application's
MediaSessionService(orMediaLibraryService)onCreate()method, initializeExoPlayerandCastPlayer. - Use
CastPlayerby default unlessRemoteCastPlayeris explicitly requested. See the "Build a CastPlayer" section in Getting started with CastPlayer. - For
CastPlayer, pass the instance directly toMediaSession.Builder. - Replace all legacy forwarding player wrappers.
- Don't delete legacy class files yet to prevent compilation errors during migration.
Advanced: RemoteCastPlayer
Use
RemoteCastPlayeronly if explicitly requested by user.Initialize
MediaSessionwithlocalPlayerand set aSessionAvailabilityListeneronRemoteCastPlayerto transfer playback state on Cast session availability changes:class PlaybackService : MediaSessionService() { private var mediaSession: MediaSession? = null private lateinit var localPlayer: ExoPlayer private lateinit var remotePlayer: RemoteCastPlayer override fun onCreate() { super.onCreate() localPlayer = ExoPlayer.Builder(this).build() remotePlayer = RemoteCastPlayer.Builder(this).build() mediaSession = MediaSession.Builder(this, localPlayer).build() remotePlayer.setSessionAvailabilityListener( object : Sess
자주 묻는 질문
어떤 Media3 버전이 필요한가요?
Cast는 이전 버전에서 사용할 수 없으므로 Media3는 1.9.0 이상이어야 합니다.
기존 Cast SDK를 써야 하나요?
아니요. 이 스킬은 기존 SDK가 유지 관리 모드에 있다고 설명하므로, 기존 SDK를 요청하지 않는 한 새 설정은 Media3 Cast를 사용해야 합니다.
Compose와 View 모두 작동하나요?
네. Compose 화면과 View 기반 화면 모두에서 Cast 재생을 다룹니다.
상세 정보
작성자의 원본 설명
Implements Google Cast support in Android apps using Jetpack Media3. Handles adding build dependencies, updating manifest, configuring OptionsProvider, and managing CastPlayer or RemoteCastPlayer for playback in both Compose and View-based UIs. Use when adding Cast functionality or migrating from legacy Cast SDK to Media3 Cast.
repo: android/skills
인기도
- GitHub 스타
- 10k
- 순위
- #11923
- 라이선스
- Apache-2.0
- 업데이트
- 2026. 10. 29.
댓글
- …
이 저장소의 다른 스킬
agp-9-upgrade
10k에이전트가 Android 앱을 Android Gradle Plugin 9로 업그레이드하고 호환되지 않는 변경 사항을 처리하도록 돕습니다. 멀티플랫폼 프로젝트는 대상이 아닙니다.
camerax
10k에이전트가 CameraX로 동영상 녹화, 하드웨어 제어, ML Kit와 Media3 효과를 포함한 Android 카메라 기능을 만들도록 돕습니다.
android-for-cars-parked-apps
10k에이전트가 Android 동영상, 게임 또는 브라우저 앱을 Android Auto와 Android Automotive의 주차 중 앱으로 실행되도록 맞추는 것을 돕습니다.
appfunctions
10k에이전트가 Android 앱의 핵심 작업 흐름을 찾아, AI 에이전트와 음성 명령이 실행할 수 있는 AppFunctions로 노출하도록 돕습니다.
비슷한 스킬
android-clean-architecture
280k에이전트가 Android 프로젝트를 효율적으로 구성하도록 돕습니다. 유지보수와 새 기능 개발이 쉽도록 코드를 구조화합니다.
compose-multiplatform-patterns
280k에이전트가 KMP 프로젝트에서 Compose Multiplatform과 Jetpack Compose 패턴을 쓰도록 돕습니다. 상태, 내비게이션, 테마, 성능을 다룹니다.
dart-flutter-patterns
280kDart와 Flutter 앱용 코드를 작성하도록 에이전트를 돕습니다. 견고하고 관리하기 쉬운 앱을 만드는 현대적인 패턴을 씁니다.