react-native-google-cast
Index
Enumerations
- ActiveInputState
- CastState
- MediaHlsSegmentFormat
- MediaHlsVideoSegmentFormat
- MediaPlayerIdleReason
- MediaPlayerState
- MediaQueueContainerType
- MediaQueueType
- MediaRepeatMode
- MediaStreamType
- PlayServicesState
- StandbyState
Classes
Interfaces
- ApplicationMetadata
- Device
- Generic
- MediaInfo
- MediaLiveSeekableRange
- MediaLoadRequest
- MediaMetadata
- MediaQueueContainerMetadata
- MediaQueueData
- MediaQueueItem
- MediaSeekOptions
- MediaStatus
- MediaTrack
- Movie
- MusicTrack
- Photo
- TextTrackStyle
- TvShow
- UseCastSessionOptions
- User
- VideoInfo
- WebImage
Type aliases
Variables
Functions
- useCastChannel
- useCastDevice
- useCastSession
- useCastState
- useDevices
- useMediaStatus
- useRemoteMediaClient
- useStreamPosition
Type aliases
DeviceCapability
Ƭ DeviceCapability: "VideoOut" | "VideoIn" | "AudioOut" | "AudioIn" | "DynamicGroup" | "MultizoneGroup" | "MultiChannelGroup"
String representing a Cast receiver device's capabilties "DynamicGroup" and "MultiChannelGroup" only available on iOS
Variables
Native
• Native: any
Const
manager
• manager: SessionManager‹› = new SessionManager()
Functions
useCastChannel
▸ useCastChannel(namespace
: string, onMessage?
: undefined | function, useCastSessionOptions?
: UseCastSessionOptions): CastChannel | null
Hook that establishes a custom CastChannel on the current connected session.
example
import { useCastChannel } from 'react-native-google-cast'
function MyComponent() {
const castChannel = useCastChannel(
'urn:x-cast:com.example.custom',
useCallback(message => { console.log('Received message', message) }, [])
)
// later, for example after pressing a button
function onPress() {
if (castChannel) {
castChannel.sendMessage('...')
}
}
}
Parameters:
Name | Type | Description |
---|---|---|
namespace | string | custom namespace starting with urn:x-cast: |
onMessage? | undefined | function | listener called when a message from the receiver was received |
useCastSessionOptions? | UseCastSessionOptions | - |
Returns: CastChannel | null
custom channel, or null
if there's no session connected
useCastDevice
▸ useCastDevice(options?
: UseCastSessionOptions): Device | null
Hook that provides the currently connected Device.
example
import { useCastDevice } from 'react-native-google-cast'
function MyComponent() {
const castDevice = useCastDevice()
if (castDevice) {
console.log(castDevice)
}
}
Parameters:
Name | Type |
---|---|
options? | UseCastSessionOptions |
Returns: Device | null
current device, or null
if there's no session connected
useCastSession
▸ useCastSession(options?
: UseCastSessionOptions): CastSession | null
Hook that provides the current CastSession.
example
import { useCastSession } from 'react-native-google-cast'
function MyComponent() {
const castSession = useCastSession()
if (castSession) {
castSession.client.loadMedia(...)
}
}
Parameters:
Name | Type |
---|---|
options? | UseCastSessionOptions |
Returns: CastSession | null
current session, or null
if there's no session connected
useCastState
▸ useCastState(): undefined | null | NO_DEVICES_AVAILABLE | NOT_CONNECTED | CONNECTING | CONNECTED
Returns: undefined | null | NO_DEVICES_AVAILABLE | NOT_CONNECTED | CONNECTING | CONNECTED
useDevices
▸ useDevices(): Device[]
Hook that listens to changes to available devices and returns current list.
Returns: Device[]
useMediaStatus
▸ useMediaStatus(): null | MediaStatus
Hook to retrieve current media status.
Note that the media status is only updated when the status of the stream changes. Therefore, mediaStatus.streamPosition
only reflects the time of the last status update.
If you need to know the current progress in near real-time, see useStreamPosition
instead.
Returns: null | MediaStatus
current media status, or null
if there's no current media
useRemoteMediaClient
▸ useRemoteMediaClient(options?
: UseCastSessionOptions): null | RemoteMediaClient‹›
Hook that provides the current RemoteMediaClient.
example
import { useRemoteMediaClient } from 'react-native-google-cast'
function MyComponent() {
const client = useRemoteMediaClient()
if (client) {
client.loadMedia(...)
}
}
Parameters:
Name | Type |
---|---|
options? | UseCastSessionOptions |
Returns: null | RemoteMediaClient‹›
current client, or null
if there's no session connected
useStreamPosition
▸ useStreamPosition(interval?
: undefined | number): null | number
Hook to retrieve current stream position.
Parameters:
Name | Type |
---|---|
interval? | undefined | number |
Returns: null | number
current position in seconds, or null
if there's no current media