Hand a queue or a paginated feed to the native side and let the OS handle playback, lock-screen controls, background audio, and route changes. Update playback config on the fly without restarting the player.Documentation Index
Fetch the complete documentation index at: https://setup.despia.com/llms.txt
Use this file to discover all available pages before exploring further.
Installation
- Bundle
- CDN
Load a queue
Useaudio://setqueue for a fixed list of tracks you have up front. The native side rebuilds the player and starts at track 0.
tracks must be a JSON string, not an object. id is required on every track, the bridge uses it to track which track is current across config updates and feed swaps. title, artist, and artwork are surfaced on the lock screen.
Load a paginated feed
Useaudio://setfeed when tracks are loaded incrementally from a server. The native side fetches the URL, plays through the returned page, then fetches the next page when the queue runs low.
setfeed with the same url= is a no-op idempotent path, the player keeps running. Re-issuing with a different url= rebuilds the player, and if the currently-playing track is not present in the new feed, playback terminates rather than silently jumping to a different track.
Playback controls
The lock-screen buttons fire these schemes automatically. Call them yourself from JS to drive your own play / pause / seek / skip UI.audio://skipforward and audio://skipback use whatever skip_interval is currently configured.
Listen for events
Attach a globalwindow.onAudioEvent function once. The native side calls it with one argument, an event object, every time the player state changes.
e.type inside it. The single-channel design keeps events ordered and easy to log.
Update config without restarting playback
Useaudio://config to change playback settings on an active player without tearing down or interrupting it. Toggle loop, change playback speed, swap which lock-screen controls show, or adjust the skip interval, the player keeps playing through the change.
| Param | Value | Effect |
|---|---|---|
controls | comma-separated list of next, prev, skipforward, skipback, seek. Empty for play/pause only. | Updates which optional lock-screen buttons render. Live. |
loop | 'true' or 'false' | Updates loop. Takes effect on the next track-end. |
skip_interval | number, in seconds | Updates the ±N button labels and the default jump distance for audio://skipforward and audio://skipback. |
speed_rate | number, clamped 0.5–3.0 | Updates playback speed live. Mid-track changes take effect immediately, no track restart. |
audio://config call, the bridge fires config_updated through window.onAudioEvent. The state object reflects the new values:
queue is not included, config_updated is not a queue-changing event. controls is not echoed back either, your JS already knows what it sent.
Choosing the right command
audio://config exists because setqueue and setfeed are heavy operations. Reach for it whenever you only need to change settings, restarting the player just to flip a control button is the wrong shape.
| Want to… | Use | Tears down the player? |
|---|---|---|
| Load a fixed list of tracks | audio://setqueue | Yes, rebuilds the player from track 0. |
| Switch to a paginated feed | audio://setfeed with a new url= | Yes, rebuilds the player. May terminate if the currently-playing track is not in the new feed. |
| Re-issue the same feed URL | audio://setfeed with the same url= | No, idempotent no-op. |
Change only controls, loop, speed_rate, or skip_interval | audio://config | No, never touches the player or queue. |
Resources
NPM Package
despia-native