Chromecast streaming from mobile app

TRUETECH is engaged in the development, support and maintenance of iOS, Android, PWA mobile applications. We have extensive experience and expertise in publishing mobile applications in popular markets like Google Play, App Store, Amazon, AppGallery and others.
Development and support of all types of mobile applications:
Information and entertainment mobile applications
News apps, games, reference guides, online catalogs, weather apps, fitness and health apps, travel apps, educational apps, social networks and messengers, quizzes, blogs and podcasts, forums, aggregators
E-commerce mobile applications
Online stores, B2B apps, marketplaces, online exchanges, cashback services, exchanges, dropshipping platforms, loyalty programs, food and goods delivery, payment systems.
Business process management mobile applications
CRM systems, ERP systems, project management, sales team tools, financial management, production management, logistics and delivery management, HR management, data monitoring systems
Electronic services mobile applications
Classified ads platforms, online schools, online cinemas, electronic service platforms, cashback platforms, video hosting, thematic portals, online booking and scheduling platforms, online trading platforms

These are just some of the types of mobile applications we work with, and each of them may have its own specific features and functionality, tailored to the specific needs and goals of the client.

Showing 1 of 1 servicesAll 1735 services
Chromecast streaming from mobile app
Medium
~2-3 business days
FAQ
Our competencies:
Development stages
Latest works
  • image_mobile-applications_feedme_467_0.webp
    Development of a mobile application for FEEDME
    756
  • image_mobile-applications_xoomer_471_0.webp
    Development of a mobile application for XOOMER
    624
  • image_mobile-applications_rhl_428_0.webp
    Development of a mobile application for RHL
    1054
  • image_mobile-applications_zippy_411_0.webp
    Development of a mobile application for ZIPPY
    947
  • image_mobile-applications_affhome_429_0.webp
    Development of a mobile application for Affhome
    862
  • image_mobile-applications_flavors_409_0.webp
    Development of a mobile application for the FLAVORS company
    445

Implementing Chromecast Streaming from a Mobile Application

Chromecast works through Google Cast SDK: the phone (Sender) controls a playback device (Receiver — Chromecast, Android TV, Google Nest). The phone doesn't stream media data through itself — it sends a URL, and the Receiver fetches the stream directly from the server.

Connecting Google Cast SDK

Android. com.google.android.gms:play-services-cast-framework:latest in build.gradle. Initialization in Application:

class App : Application() {
    override fun onCreate() {
        super.onCreate()
        val options = CastOptions.Builder()
            .setReceiverApplicationId(CastMediaControlIntent.DEFAULT_MEDIA_RECEIVER_APPLICATION_ID)
            .build()
        CastContext.getSharedInstance(this, executor).addOnSuccessListener { castContext ->
            // Cast context is ready
        }
    }
}

DEFAULT_MEDIA_RECEIVER_APPLICATION_ID is the standard Default Media Receiver that plays HLS, DASH, MP4, MP3. For a custom Receiver (your own web application on Chromecast) — register in Google Cast Developer Console and use your own App ID.

iOS. pod 'google-cast-sdk' (CocoaPods) or GoogleCast via SPM (unofficial). API is similar to Android.

Cast Button in UI

Google Cast SDK automatically provides UICastButton (iOS) / MediaRouteButton (Android) — standard Cast icon that displays the list of available devices and changes appearance when connected:

// In menu toolbar
override fun onCreateOptionsMenu(menu: Menu): Boolean {
    menuInflater.inflate(R.menu.menu_player, menu)
    CastButtonFactory.setUpMediaRouteButton(this, menu, R.id.media_route_menu_item)
    return true
}

For Jetpack Compose — AndroidView with MediaRouteButton.

Starting Playback on Receiver

val castSession = CastContext.getSharedInstance(context).sessionManager.currentCastSession
val remoteClient = castSession?.remoteMediaClient ?: return

val mediaMetadata = MediaMetadata(MediaMetadata.MEDIA_TYPE_MOVIE).apply {
    putString(MediaMetadata.KEY_TITLE, "Movie Title")
    putString(MediaMetadata.KEY_SUBTITLE, "Description")
    addImage(WebImage(Uri.parse(thumbnailUrl)))
}

val mediaInfo = MediaInfo.Builder(streamUrl)
    .setStreamType(MediaInfo.STREAM_TYPE_BUFFERED)
    .setContentType("application/x-mpegURL") // HLS, or video/mp4 for MP4
    .setMetadata(mediaMetadata)
    .build()

val loadOptions = MediaLoadRequestData.Builder()
    .setMediaInfo(mediaInfo)
    .setAutoplay(true)
    .setCurrentTime(startPositionMs.toLong())
    .build()

remoteClient.load(loadOptions)

Playback Control

RemoteMediaClient is the central object for all commands: play(), pause(), seek(position), setStreamVolume(volume). State is accessed through RemoteMediaClient.Callback:

remoteClient.registerCallback(object : RemoteMediaClient.Callback() {
    override fun onStatusUpdated() {
        val status = remoteClient.mediaStatus ?: return
        val position = status.streamPosition
        val isPlaying = status.playerState == MediaStatus.PLAYER_STATE_PLAYING
        updateUI(isPlaying, position)
    }
})

Mini Controller and Expanded Controller

Google Cast SDK provides ready-made UI components: MiniControllerFragment — a control bar at the bottom of the screen (similar to a mini-player), ExpandedControllerActivity — a fullscreen Cast player. Connected declaratively — minimal code required.

Cast Session and Reconnection

When Wi-Fi connection is lost, CastSession transitions to TEMPORARILY_DISCONNECTED state. After 3 minutes — DISCONNECTED. SessionManagerListener.onSessionSuspended / onSessionResumed — handle reconnection, resume playback from saved position.

If the user closed the application and returned — Cast SDK automatically restores the session through CastContext.sessionManager.currentCastSession. Check on app startup and show the Cast mini-controller if a session is active.

Chromecast on React Native and Flutter

React Native: react-native-google-cast (github.com/react-native-google-cast) — unofficial wrapper. Stable for basic scenarios (starting video, pause, seeking), but extended functionality (queue, custom data) requires native code through bridge.

Flutter: no official package. flutter_google_cast (pub.dev) — community package with unstable support. For production, we recommend native implementation through MethodChannel.

Timeline

Basic Chromecast streaming with Cast button, playback launch and mini-controller — 2–3 days. Custom Receiver (web application) — a separate task, plus 2–3 days.