← Recipe: play packaged audio

6. Separate command completion from live truth

luastra/media · live media_state events · about 20 minutes
resolve acknowledges · media_state observes

A completed command and current playback are related signals, not interchangeable promises.

When to use it

Read this when controls appear to lag, playback changes outside the app, or command success conflicts with a later media event.

  • setQueue, play, and pause return RequestId immediately; store it only for command correlation.
  • app.resolve reports whether that command completed and may carry a decodable state snapshot.
  • media_state reports later changes such as progress, ending, buffering, interruption, route, and errors.
  • Render from the newest decoded Media.State rather than assuming that a pressed button already changed playback.
  • Ignore unknown RequestIds and reject malformed state payloads without erasing the last valid UI state.

Complete inventory

View all pages in Recipe: play packaged audio
← Previous: 5. Check and runNext: 7. Understand sources and queues →