← Audio and media queue

Media.DecodeResult

luastra/media

Media.DecodeResult is a discriminated union covering successful output and bounded failure. Branching on success narrows the value to the correct exported record and makes error handling explicit.

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.DecodeResult at the boundary where untrusted or versioned input is decoded. Branch on result.success before reading value or error so both outcomes remain explicit and type-safe.

Fields or definition

ParameterType / valuesDescription
definitionDecodeSuccess | DecodeFailureExact alias, union, or callable contract represented by Media.DecodeResult.

Error codes

This is the complete closed vocabulary emitted by the named operation in this Source SDK contract.

CodeWhen it occurs
invalid_wireThe media-state wire payload cannot be decoded.
missing_fieldA required media-state field is absent.
invalid_stateThe field set, status, or background flag is invalid.
invalid_numberA required numeric field is not a valid number.
invalid_errorThe host error code and message fields are inconsistent.

SDK type flow

Produced by

Media.decodeState

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 DecodeResult = DecodeSuccess | DecodeFailure

Continue learning

Prerequisites

Media.DecodeSuccess

Companions

Media.State

Next steps

Media.decodeState

Complete inventory

View all pages in Audio and media queue
← Previous: Media.DecodeFailureNext: Media.setQueue →