Skip to content

Events

nari.on(event, handler) calls handler every time something happens. A plugin can have several handlers for the same event.

nari.on("state", function(state)
nari.log(state.playing and "playing" or "paused", "at", state.position, "ms")
end)
Event Arguments When
ready — Nari finished starting.
disable — The plugin is being turned off.
track song or nil The current song changed, nil when the queue ends. Also fires when the plugin turns on mid-song.
state { playing, position } Playback started or paused. position is in milliseconds.
played song A song counted as listened: half of it or 4 minutes, for songs at least 30 seconds long. song has plays and last_played. Threads get it too, even with the screen off.
link url A nari://plugin/<your id>/… link was opened. See Links into Nari.
page name, page, data A screen opened. See below.

An error inside a handler is logged and doesn’t stop the other handlers.

Background threads get track, state and message.

name is one of Home, Tracks, Albums, Artists, Playlists, Album, Artist, Playlist, NowPlaying, Settings, Soundboard, Search or Welcome. page is the screen’s node and data its arguments, like data.category for Settings. Building UI shows what to do with it.

On the main thread song is the full song from the library, with at least:

id, title, artist, artists (list), artist_id, album, album_id, duration (ms), track_number, disc_number, year, genres (list) and file_name.

In background threads it has id, title, artist, artists, album, album_artist and duration (ms).