wolfhacklua API 1.1 Forum

media

The track playing in the system's media session (Spotify, a browser, ...) and its controls.

since 1.0no permission needed

Always available. media.get() returns available = false when the system's media session cannot be used. Using the media functions keeps the overlay's media thread running, so only call them from scripts that show the track.

Reference#

media.get#since 1.0

media.get(): MediaInfo

What is playing now.

ReturnsDescription
MediaInfoSee MediaInfo.
lua
local m = media.get()
if m.has_session and m.playing then log.info(m.artist .. " - " .. m.title) end

media.cover#since 1.0

media.cover(): Texture | nil

The cover picture as a texture. It loads in the background; check m.has_cover and tex:ready().

ReturnsDescription
Texture | nilThe current cover, or nil.

media.control#since 1.0

media.control(what: string)

Presses a transport control. Check can_toggle, can_next and can_previous first.

ParameterTypeDescription
whatstring"toggle", "next", "previous", "shuffle" or "repeat".

media.seek#since 1.0

media.seek(seconds: number)

Seeks within the track when can_seek is true.

ParameterTypeDescription
secondsnumberThe position to jump to.

MediaInfo#

What media.get() returns.

FieldTypeDescription
availablebooleanThe media session can be used.
has_sessionbooleanSomething is registered as playing.
titlestringTrack title.
artiststringArtist.
albumstringAlbum.
appstringThe playing application.
playingbooleanPlaying (not paused).
can_togglebooleanPlay/pause works.
can_nextbooleanNext works.
can_previousbooleanPrevious works.
can_seekbooleanSeeking works.
shufflebooleanShuffle is on.
repeatintegerRepeat mode.
positionnumberSeconds into the track.
durationnumberTrack length in seconds.
track_keystringAn id that changes with the track.
has_coverbooleanA cover exists.
cover_loadingbooleanThe cover is still loading.
accent{r, g, b} | nilA colour taken from the cover.
API 1.1 · source docs-src/api/media.json