मुख्य सामग्री पर जाएँ
Skillpedia
मोबाइल ऐप10k · #11923

media3-cast-integration

यह क्या करती है

यह स्किल Media3 लाइब्रेरी से Android ऐप में Google Cast प्लेबैक जोड़ने का मार्गदर्शन देती है। इसमें dependencies, manifest, Cast options और Compose व View स्क्रीन के लिए player शामिल हैं। यह उन Android डेवलपरों के लिए है जो Cast सपोर्ट चाहते हैं या पुराने Cast SDK से हट रहे हैं।

कब इस्तेमाल करें

  • ✓जब आप चाहते हैं कि उपयोगकर्ता आपके Android ऐप से वीडियो या ऑडियो को TV या स्पीकर पर कास्ट करें।
  • ✓जब आपको पुराने Google Cast SDK से Media3 Cast पर जाना हो।
  • ✓जब आपको Compose या View ऐप में Cast player और options provider सेट करने हों।

Skill का लिंक

https://github.com/android/skills/blob/main/media/media3-cast-integration/SKILL.md

इसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।

कैसे इस्तेमाल करें

सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।

पेस्ट करने के लिए तैयार मैसेज

इस skill से मेरी मदद करो: https://github.com/android/skills/blob/main/media/media3-cast-integration/SKILL.md इस लिंक की SKILL.md फ़ाइल पढ़ो और मेरे काम में उसके निर्देशों का पालन करो।
क्या आप चाहते हैं कि आपका AI ऐसी skills खुद ढूँढे?मुफ़्त Skillpedia MCP इंस्टॉल करें: बस एक लाइन, और हर काम से पहले यह 15,000+ skills में खोजता है।1 मिनट में इंस्टॉल करें →

AI से क्या माँगें: उदाहरण

“मेरे Android वीडियो ऐप में Media3 से Google Cast जोड़िए, ताकि उपयोगकर्ता अपने TV पर कास्ट कर सकें।”

हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।

यह कैसे काम करती है

स्किल जाँचती है कि Media3 वर्शन 1.9.0 या नया है, फिर ज़रूरी dependencies और manifest एंट्री जोड़ती है। फिर वह ऐप की स्क्रीन के लिए Cast options और Cast player सेट करती है।

तकनीकी सामग्री (मूल SKILL.md)

लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे GitHub से।

Prerequisites

  • Jetpack Media3 version must be >= 1.9.0. Cast isn't available in lower versions.

Glossary

  • CastPlayer : Media3 Player that controls playback on both local and remote Cast devices.
  • RemoteCastPlayer : Media3 Player that 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 GMS CastContext.

Common guidelines

Step 1: Set up dependencies

To complete this step, you MUST ensure the following:

  • In the app-level build file, declare the media3-cast dependency version 1.9.0 or higher.

    implementation("androidx.media3:media3-cast:1.11.1")
    
  • Ensure required Media3 dependencies are present:

    • androidx.media3:media3-exoplayer
    • androidx.media3:media3-session
    • androidx.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.
  • 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 DefaultCastOptionsProvider by default. See the "OptionsProvider" section in Getting started with CastPlayer.
  • Declare a custom OptionsProvider only if explicitly requested. See Customize CastOptions.
  • Ensure INTERNET permission 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 ExoPlayer only to support local playback.
  • Legacy Cast setup: Uses ExoPlayer for local playback, alongside a Player wrapper over the legacy RemoteMediaClient for remote playback. The UI interfaces with a MediaSession interacting with a ForwardingPlayer, which finally routes controls to either local or remote playback.

To complete this step, you MUST ensure the following:

  • Inside the application's MediaSessionService (or MediaLibraryService) onCreate() method, initialize ExoPlayer and CastPlayer.
  • Use CastPlayer by default unless RemoteCastPlayer is explicitly requested. See the "Build a CastPlayer" section in Getting started with CastPlayer.
  • For CastPlayer, pass the instance directly to MediaSession.Builder.
  • Replace all legacy forwarding player wrappers.
  • Don't delete legacy class files yet to prevent compilation errors during migration.

Advanced: RemoteCastPlayer

  • Use RemoteCastPlayer only if explicitly requested by user.

  • Initialize MediaSession with localPlayer and set a SessionAvailabilityListener on RemoteCastPlayer to 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 वर्शन चाहिए?

Media3 वर्शन 1.9.0 या नया होना चाहिए, क्योंकि Cast पहले के वर्शन में उपलब्ध नहीं है।

क्या मुझे पुराना Cast SDK इस्तेमाल करना चाहिए?

नहीं। स्किल कहती है कि पुराना SDK maintenance mode में है, इसलिए नए सेटअप में Media3 Cast इस्तेमाल करें, जब तक आप पुराने SDK के लिए न कहें।

क्या यह Compose और Views दोनों के साथ काम करता है?

हाँ। यह 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
अपडेट की गई
29/10/2026

क्या यह skill काम की है?

0

लॉग इन करें वोट करने के लिए।

कमेंट

  • …

इस repository की और skills

agp-9-upgrade

10k

आपके एजेंट को Android ऐप को Android Gradle Plugin 9 पर ले जाने और उसके breaking changes सुधारने में मदद करती है। मल्टीप्लेटफ़ॉर्म प्रोजेक्ट के लिए नहीं।

कोडिंगमोबाइल ऐप

camerax

10k

आपके एजेंट को CameraX से Android कैमरा फ़ीचर बनाने में मदद करती है, जिसमें वीडियो रिकॉर्डिंग, हार्डवेयर कंट्रोल, ML Kit और Media3 इफ़ेक्ट शामिल हैं।

कोडिंगमोबाइल ऐप

android-for-cars-parked-apps

10k

आपके एजेंट को Android वीडियो, गेम या ब्राउज़र ऐप को Android Auto और Android Automotive पर parked ऐप के रूप में चलाने के लिए ढालने में मदद करती है।

कोडिंगमोबाइल ऐप

appfunctions

10k

आपके एजेंट को Android ऐप के मुख्य काम ढूँढकर उन्हें AppFunctions के रूप में देने में मदद करती है, ताकि AI एजेंट और वॉइस कमांड उन्हें चला सकें।

AI और एजेंटएजेंट

मिलती-जुलती skills