React Native Google Cast

React Native Google Cast

  • Docs
  • GitHub

›API

Getting Started

  • Installation
  • Setup
  • Usage
  • Troubleshooting

Guides

  • Custom Channels
  • Customize UI
  • Events
  • Hooks
  • Media Tracks
  • Queueing
  • Volume

Components

  • CastButton
  • ExpandedController

API

  • CastChannel
  • CastContext
  • CastSession
  • DiscoveryManager
  • RemoteMediaClient
  • SessionManager

Types

  • ApplicationMetadata
  • Device
  • MediaInfo
  • MediaLiveSeekableRange
  • MediaLoadRequest
  • MediaMetadata
    • Generic
    • Movie
    • MusicTrack
    • Photo
    • TvShow
    • User
  • MediaQueueContainerMetadata
  • MediaQueueData
  • MediaQueueItem
  • MediaSeekOptions
  • MediaStatus
  • MediaTrack
  • TextTrackStyle
  • UseCastSessionOptions
  • VideoInfo
  • WebImage

Enums

  • ActiveInputState
  • CastState
  • MediaHlsSegmentFormat
  • MediaHlsVideoSegmentFormat
  • MediaPlayerIdleReason
  • MediaPlayerState
  • MediaQueueContainerType
  • MediaQueueType
  • MediaRepeatMode
  • MediaStreamType
  • PlayServicesState
  • StandbyState

DiscoveryManager

A class that manages the device discovery process.

The framework automatically starts the discovery process when the application moves to the foreground and suspends it when the application moves to the background. On iOS, it is possible to use startDiscovery/stopDiscovery, as an optimization measure to reduce network traffic and CPU utilization in areas of the application that do not use Cast functionality.

If the application is using the framework's Cast dialog, then that dialog will use DiscoveryManager to populate its list of available devices. If however the application is providing its own device selection/control dialog UI, then it should use getDevices and onDevicesUpdated to populate and update its list of available devices.

see iOS | Android

example

import GoogleCast from 'react-native-google-cast'

function MyComponent() {
  const discoveryManager = GoogleCast.getDiscoveryManager()
  discoveryManager.startDiscovery()
}

Hierarchy

  • DiscoveryManager

Index

Methods

  • getDevices
  • isPassiveScan
  • isRunning
  • onDevicesUpdated
  • setPassiveScan
  • startDiscovery
  • stopDiscovery

Methods

getDevices

▸ getDevices(): Promise‹Device[]›

List currently available devices.

Returns: Promise‹Device[]›


isPassiveScan

▸ isPassiveScan(): Promise‹boolean›

(iOS only) A flag indicating whether discovery should employ a "passive" scan. Passive scans are less resource-intensive but do not provide results that are as fresh as active scans.

Returns: Promise‹boolean›


isRunning

▸ isRunning(): Promise‹boolean›

(iOS only) Check whether discovery is currently running, i.e. it either started automatically, or user initially pressed a Cast button, or startDiscovery has been called.

Returns: Promise‹boolean›


onDevicesUpdated

▸ onDevicesUpdated(listener: function): EmitterSubscription

Listen for changes to the list of devices.

Hint Use the useDevices hook instead that manages getDevices and onDevicesUpdated for you.

example

const subscription = GoogleCast.getDiscoverManager().onDevicesUpdated(devices => {
  // ... display a list of devices
})

// later, to stop listening
subscription.remove()

Parameters:

▪ listener: function

▸ (devices: Device[]): void

Parameters:

NameType
devicesDevice[]

Returns: EmitterSubscription


setPassiveScan

▸ setPassiveScan(on: boolean): Promise‹void›

(iOS only)* Set whether to use "passive" scan for discovery.

Parameters:

NameType
onboolean

Returns: Promise‹void›


startDiscovery

▸ startDiscovery(): Promise‹void›

(iOS only) Starts the device discovery process.

Returns: Promise‹void›


stopDiscovery

▸ stopDiscovery(): Promise‹void›

(iOS only) Stops the device discovery process.

Returns: Promise‹void›

← CastSessionRemoteMediaClient →
  • Hierarchy
  • Index
    • Methods
  • Methods
    • getDevices
    • isPassiveScan
    • isRunning
    • onDevicesUpdated
    • setPassiveScan
    • startDiscovery
    • stopDiscovery