Function: useIsCasting()
function useIsCasting(): boolean;
Defined in: packages/cast/src/use-cast-state.ts:75
Whether playback is being served by a receiver right now.
The boolean an app actually branches on: "is the phone the output, or is a
Chromecast?". It rides the same subscription as useCastState and
re-renders only when the answer flips — the four non-casting states collapse
to false, so idle → connecting costs no render in a component that only
asked this question.
'transferring' counts as casting, deliberately: that state is a
receiver-to-receiver stream transfer (Android's output switcher moving a
session between speakers), during which the phone is still not the output
and the session is still alive. Treating it as "not casting" would make a UI
flicker back to local controls mid-transfer and let the app issue local
commands that the handoff machine is about to override.
Returns
boolean
true while the connection state is 'connected' or
'transferring'.
Example
import { useIsCasting } from '@afkcodes/timbre-cast'
function VolumeRow() {
const casting = useIsCasting()
// While casting the volume slider drives the RECEIVER's device volume.
return <Slider onChange={casting ? setDeviceVolume : setPlayerVolume} />
}