Media.State
luastra/mediaMedia.State is an exported, statically checked data contract of luastra/media. Its exact declaration documents the fields or alternatives accepted at the module boundary and is erased after Luau analysis.
Before you use it
Add luastra/media to this module's dependencies in luastra.json, then import it with require("luastra/media"). Declare media.command in luastra.json. Set an admitted queue before playback, start playback from an explicit user action where required, and implement both app.resolve and media_state handling.
How it fits
The type describes queue input, live playback state, or the tagged state-decoding result.
When to use it
Use Media.State when annotating values that cross the public luastra/media boundary or when exporting helpers built on that module. The type documents the exact checked shape and prevents unrelated tables from being substituted accidentally.
Fields or definition
| Parameter | Type / values | Description |
|---|---|---|
| revision | number | Checked revision field of Media.State; its exact admitted type is number. |
| status | string | Checked status field of Media.State; its exact admitted type is string. |
| itemId | string | Checked itemId field of Media.State; its exact admitted type is string. |
| title | string | Checked title field of Media.State; its exact admitted type is string. |
| artist | string | Checked artist field of Media.State; its exact admitted type is string. |
| positionMs | number | Current playback position in milliseconds. |
| durationMs | number | Known media duration in milliseconds, or the declared optional form. |
| bufferedMs | number | Checked bufferedMs field of Media.State; its exact admitted type is number. |
| queueIndex | number | Checked queueIndex field of Media.State; its exact admitted type is number. |
| queueCount | number | Checked queueCount field of Media.State; its exact admitted type is number. |
| background | boolean | Checked background field of Media.State; its exact admitted type is boolean. |
| interruption | string | Checked interruption field of Media.State; its exact admitted type is string. |
| route | string | Checked route field of Media.State; its exact admitted type is string. |
| error | MediaError? | Bounded failure information, or nil on the successful branch. |
What happens next
A checked media input/state/result annotation.
Failures and fixes
Missing capability, absent queue, invalid asset/content URI, autoplay policy, interruption, unsupported background behavior, or host failure must remain visible state. Do not optimistically treat command acknowledgement as playback success.
Availability
Public-source alpha API in 0.5.0-alpha; background playback and system controls require target-specific verification.
Exact declaration
export type State = {
revision: number, status: string, itemId: string, title: string, artist: string,
positionMs: number, durationMs: number, bufferedMs: number, queueIndex: number, queueCount: number,
background: boolean, interruption: string, route: string, error: MediaError?,
}Continue with a complete recipe
This checked recipe uses Media.State inside complete authored files with the required manifest, test, and run steps.
Open play packaged audio recipe