@afkcodes/timbre-cast
Classes
| Class | Description |
|---|---|
| CastError | - |
Interfaces
| Interface | Description |
|---|---|
| CanCastInput | Castability heuristic against the Google Cast receiver codec table. |
| CanCastVerdict | - |
| CastApi | The public cast surface. |
| CastButtonProps | Props of CastButton. |
| CastDeviceInfo | A discovered cast receiver. |
| CastEventMap | Payload delivered for each event name. queueChanged carries nothing — void keeps () => void assignable as a listener. |
| CastHandoff | The running handoff — one per app; dispose before creating another. |
| CastHandoffLocalPlayer | The 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.) |
| CastHandoffQueueItem | One 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. |
| CastHandoffQueueSnapshot | The atomic read taken at handoff time: queue, cursor, clock, intent. |
| CastHandoffTransition | - |
| CastInitOptions | - |
| CastLoadOptions | Options for a single-item RnMediaCast.load. |
| CastMediaMetadata | Metadata projected onto the receiver's now-playing surface. |
| CastMediaSource | One castable media source. The receiver fetches url itself. |
| CastQueueItemInput | One receiver-queue entry for RnMediaCast.queueLoad / inserts. |
| CastQueueItemSnapshot | One row of the sender-side queue mirror. |
| CastQueueLoadOptions | Options for RnMediaCast.queueLoad. |
| CastQueueProjection | The 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. |
| CastReceiverSnapshot | The 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. |
| CastStateEvent | Connection-state change, as the JS layer sees it. |
| CastTransferEvent | A transfer discontinuity — one per direction per handoff. |
| EndSessionOptions | - |
| NativeCastDevicesEvent | Discovery produced a new device list (already debounced natively). |
| NativeCastMediaErrorEvent | Receiver-side media failure. The TS layer folds this into the cast-receiver-fetch error family. |
| NativeCastMediaStatusEvent | Receiver media-status discontinuity. |
| NativeCastSessionEvent | Session lifecycle notification. |
| NativeCastStateEvent | Connection-state discontinuity. |
| NativeDeviceVolumeEvent | Physical device volume (the primary volume layer while casting). |
| RnMediaCast | First-party binding over the official Google Cast sender SDKs (play-services-cast-framework on Android, google-cast-sdk on iOS), audio-scoped. |
| RnMediaCastButtonProps | Props of the native cast button view. |
| SkippedCastItem | A queue entry the projection left out — typed, surfaced, never silent. |
| WireCastHandoffOptions | - |
Type Aliases
| Type Alias | Description |
|---|---|
| CastConnectionState | The cast connection state machine, identical on both platforms. |
| CastDeviceVolume | Physical device volume state. |
| CastErrorCode | Why a @afkcodes/timbre-cast call or session failed. |
| CastEventName | - |
| CastHandoffEffect | What the reducer asks the orchestrator to do. Executed in array order. |
| CastHandoffEvent | Everything that can move the machine. at fields are stamped by the caller (the orchestrator) so the reducer itself never reads a clock. |
| CastHandoffPhase | The five phases of cast.md §3, in wire-format casing. |
| CastHandoffState | - |
| CastIdleReason | Why 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). |
| CastMediaStatus | Receiver media-status discontinuity. Identical to the bridge struct — the facade re-exposes it under a stable public name so the spec can evolve independently. |
| CastPlayerState | Receiver player state, mapped 1:1 from MediaStatus.PLAYER_STATE_* (Android) / GCKMediaPlayerState (iOS). |
| CastRepeatMode | Receiver queue repeat mode (MediaStatus.REPEAT_MODE_* / GCKMediaRepeatMode). |
| CastSeekResumeState | What the receiver should do after a seek completes. Maps to MediaSeekOptions.setResumeState / GCKMediaSeekOptions.resumeState. |
| CastSessionEvent | Session lifecycle notification. |
| CastSessionEventType | Session lifecycle notifications, fanned in from SessionManagerListener<CastSession> (Android) and GCKSessionManagerListener (iOS), plus Android's SessionTransferCallback for the output-switcher stream transfer. |
| RnMediaCastButton | The native Google Cast button, as a React Native view. |
| Unsubscribe | Removes the listener it was returned from. Idempotent. |
Variables
| Variable | Description |
|---|---|
| Cast | The process-wide cast surface. |
| castabilityTables | Exported for tests: the tables are the spec, so tests pin them. |
| initialCastHandoffState | - |
Functions
| Function | Description |
|---|---|
| canCastMedia | Can this item be handed to a Cast receiver? |
| CastButton | The platform's own Cast button. |
| createCast | Build a CastApi on top of a native hybrid object. |
| errorFromIdleReason | Classify a receiver idle reason into what it means for playback. |
| isCastingState | The single definition of "casting" shared by useIsCasting and any non-React caller, so the two can never drift. |
| projectCastQueue | Build the castable projection of a queue snapshot. |
| projectReceiverPosition | Project a receiver anchor to at — the same rule every position surface uses. |
| receiverFetchError | Build the one cast-receiver-fetch error, optionally enriched with the receiver's own detail. |
| reduceCastHandoff | The §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. |
| toCastError | Native 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. |
| useCastState | The live cast connection state, as renderable React state. |
| useIsCasting | Whether playback is being served by a receiver right now. |
| wireCastHandoff | Wire the handoff between a local player and the cast surface. |