media3-cast-integration

Implement Google Cast playback in Android apps using Jetpack Media3 CastPlayer.

2|Updated Jun 21, 2026
One-click install
npx skills add https://github.com/IsKenKenYa/skills --skill media3-cast-integration-iskenkenya
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: media3-cast-integration
Source: https://github.com/IsKenKenYa/skills/tree/main/skills/android/media/media3-cast-integration
Command: npx skills add https://github.com/IsKenKenYa/skills --skill media3-cast-integration-iskenkenya

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Adding Google Cast support to an Android media app involves many error-prone steps: declaring the right Media3 dependencies, configuring the manifest OptionsProvider, wiring CastPlayer into a MediaSessionService, and handling UI in both Compose and View-based layouts. This Skill guides the entire integration and migration from the legacy Cast SDK. ## Core Features & Use Cases - Dependency and Manifest Setup: Ensures media3-cast 1.9.0+ dependencies, DefaultCastOptionsProvider declaration, and correct permissions. - Player Architecture: Initializes ExoPlayer and CastPlayer (or RemoteCastPlayer) inside a MediaSessionService with playback state transfer between local and remote devices. - Compose and View UI Guidance: Integrates the MediaRouteButton composable or MediaRouteButtonFactory, with recomposition and rebinding logic on device changes. - Legacy Migration: Replaces legacy Cast SDK wrappers and forwarding players, with a guarded cleanup step for old dependencies. - Use Case: You have an ExoPlayer-based video app and want users to cast to Chromecast or Android TV; this Skill walks through every required change end to end. ## Quick Start Add Google Cast support to my Android media app using Jetpack Media3 CastPlayer, including the manifest setup and a Compose MediaRouteButton.

Frequently Asked Questions about media3-cast-integration

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add Google Cast to an Android app with Media3?

Add the androidx.media3:media3-cast dependency (1.9.0 or higher), declare DefaultCastOptionsProvider in your manifest, then build a CastPlayer with ExoPlayer as the local player inside a MediaSessionService and pass it to MediaSession.Builder.

How to migrate from legacy Cast SDK to Media3 CastPlayer?

Add Media3 Cast dependencies first while keeping legacy ones to avoid compile errors, replace forwarding player wrappers with CastPlayer, swap CastButtonFactory for MediaRouteButtonFactory, and only remove legacy dependencies and files when explicitly ready.

What is the difference between CastPlayer and RemoteCastPlayer?

CastPlayer manages both local and remote playback and is the default choice. RemoteCastPlayer only handles remote playback and requires a SessionAvailabilityListener to transfer playback state between a local ExoPlayer and the remote player.

Does Media3 Cast work with Jetpack Compose?

Yes. Use the MediaRouteButton composable from androidx.media3.cast and the Material3 Player composable, avoiding AndroidView wrappers. Force recomposition on DeviceInfo changes so the UI stays in sync when playback moves between devices.

Why does PlayerView show a black screen after switching to Cast?

PlayerView does not rebind when the player instance check passes. On onDeviceInfoChanged, set playerView.player to null and then back to the controller to force the video surface to rebind.

What Media3 version is required for Cast support?

Cast requires Jetpack Media3 version 1.9.0 or higher; it is not available in lower versions. All Media3 dependencies such as media3-exoplayer, media3-session, and media3-cast should use the same version.