Skip to main content

@afkcodes/timbre-cast

Classes

ClassDescription
CastError-

Interfaces

InterfaceDescription
CanCastInputCastability heuristic against the Google Cast receiver codec table.
CanCastVerdict-
CastApiThe public cast surface.
CastButtonPropsProps of CastButton.
CastDeviceInfoA discovered cast receiver.
CastEventMapPayload delivered for each event name. queueChanged carries nothing — void keeps () => void assignable as a listener.
CastHandoffThe running handoff — one per app; dispose before creating another.
CastHandoffLocalPlayerThe only things the handoff needs from a local player — the write side. (The read side is the WireCastHandoffOptions.snapshot provider: one atomic queue+cursor+clock read at handoff time.)
CastHandoffQueueItemOne JS-queue entry, as the handoff needs to see it: enough to decide castability (canCastMedia) and to build the receiver-side CastMediaSource. Structural on purpose — apps project their own queue model into this, the same discipline as audio-session's AudioSessionPlayerLike.
CastHandoffQueueSnapshotThe atomic read taken at handoff time: queue, cursor, clock, intent.
CastHandoffTransition-
CastInitOptions-
CastLoadOptionsOptions for a single-item RnMediaCast.load.
CastMediaMetadataMetadata projected onto the receiver's now-playing surface.
CastMediaSourceOne castable media source. The receiver fetches url itself.
CastQueueItemInputOne receiver-queue entry for RnMediaCast.queueLoad / inserts.
CastQueueItemSnapshotOne row of the sender-side queue mirror.
CastQueueLoadOptionsOptions for RnMediaCast.queueLoad.
CastQueueProjectionThe castable projection of a JS-queue snapshot. items[p] came from snapshot.items[jsIndices[p]] — the parallel array is one half of the reconciliation mapping; the receiver-assigned itemIds (learned after queueLoad) are the other.
CastReceiverSnapshotThe receiver's state, reconciled to JS-queue vocabulary — what the app maps into its setPlaybackState/setMediaItem broadcasts while cast-active. {position, at, rate} is a position anchor in the library-wide sense: broadcast on discontinuities, projected locally in between.
CastStateEventConnection-state change, as the JS layer sees it.
CastTransferEventA transfer discontinuity — one per direction per handoff.
EndSessionOptions-
NativeCastDevicesEventDiscovery produced a new device list (already debounced natively).
NativeCastMediaErrorEventReceiver-side media failure. The TS layer folds this into the cast-receiver-fetch error family.
NativeCastMediaStatusEventReceiver media-status discontinuity.
NativeCastSessionEventSession lifecycle notification.
NativeCastStateEventConnection-state discontinuity.
NativeDeviceVolumeEventPhysical device volume (the primary volume layer while casting).
RnMediaCastFirst-party binding over the official Google Cast sender SDKs (play-services-cast-framework on Android, google-cast-sdk on iOS), audio-scoped.
RnMediaCastButtonPropsProps of the native cast button view.
SkippedCastItemA queue entry the projection left out — typed, surfaced, never silent.
WireCastHandoffOptions-

Type Aliases

Type AliasDescription
CastConnectionStateThe cast connection state machine, identical on both platforms.
CastDeviceVolumePhysical device volume state.
CastErrorCodeWhy a @afkcodes/timbre-cast call or session failed.
CastEventName-
CastHandoffEffectWhat the reducer asks the orchestrator to do. Executed in array order.
CastHandoffEventEverything that can move the machine. at fields are stamped by the caller (the orchestrator) so the reducer itself never reads a clock.
CastHandoffPhaseThe five phases of cast.md §3, in wire-format casing.
CastHandoffState-
CastIdleReasonWhy the receiver went idle. Mapped from MediaStatus.IDLE_REASON_* / GCKMediaPlayerIdleReason. error is the receiver-side failure family — the receiver fetches media itself, so this is distinct from any sender-side network error (cast-receiver-fetch in the TS error taxonomy).
CastMediaStatusReceiver media-status discontinuity. Identical to the bridge struct — the facade re-exposes it under a stable public name so the spec can evolve independently.
CastPlayerStateReceiver player state, mapped 1:1 from MediaStatus.PLAYER_STATE_* (Android) / GCKMediaPlayerState (iOS).
CastRepeatModeReceiver queue repeat mode (MediaStatus.REPEAT_MODE_* / GCKMediaRepeatMode).
CastSeekResumeStateWhat the receiver should do after a seek completes. Maps to MediaSeekOptions.setResumeState / GCKMediaSeekOptions.resumeState.
CastSessionEventSession lifecycle notification.
CastSessionEventTypeSession lifecycle notifications, fanned in from SessionManagerListener<CastSession> (Android) and GCKSessionManagerListener (iOS), plus Android's SessionTransferCallback for the output-switcher stream transfer.
RnMediaCastButtonThe native Google Cast button, as a React Native view.
UnsubscribeRemoves the listener it was returned from. Idempotent.

Variables

VariableDescription
CastThe process-wide cast surface.
castabilityTablesExported for tests: the tables are the spec, so tests pin them.
initialCastHandoffState-

Functions

FunctionDescription
canCastMediaCan this item be handed to a Cast receiver?
CastButtonThe platform's own Cast button.
createCastBuild a CastApi on top of a native hybrid object.
errorFromIdleReasonClassify a receiver idle reason into what it means for playback.
isCastingStateThe single definition of "casting" shared by useIsCasting and any non-React caller, so the two can never drift.
projectCastQueueBuild the castable projection of a queue snapshot.
projectReceiverPositionProject a receiver anchor to at — the same rule every position surface uses.
receiverFetchErrorBuild the one cast-receiver-fetch error, optionally enriched with the receiver's own detail.
reduceCastHandoffThe §3 machine as a pure transition function. Events that are meaningless in the current phase are ignored (state unchanged, no effects) — remote surfaces and platform callbacks fire at times the machine cannot forbid, so "ignore what cannot apply" is the safe contract; every meaningful cell is handled explicitly below and exercised by the unit suite.
toCastErrorNative rejections cross the bridge as plain Errors whose message carries a [<code>] marker from the closed set above (the spec's error contract). This is the single place that turns one into a typed CastError; anything unmarked becomes code: 'native' with the original text in raw — never swallowed, never guessed at.
useCastStateThe live cast connection state, as renderable React state.
useIsCastingWhether playback is being served by a receiver right now.
wireCastHandoffWire the handoff between a local player and the cast surface.