media
The track playing in the system's media session (Spotify, a browser, ...) and its controls.
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(): MediaInfoWhat is playing now.
| Returns | Description |
|---|---|
MediaInfo | See MediaInfo. |
local m = media.get()
if m.has_session and m.playing then log.info(m.artist .. " - " .. m.title) endmedia.cover#since 1.0
media.cover(): Texture | nilThe cover picture as a texture. It loads in the background; check m.has_cover and tex:ready().
| Returns | Description |
|---|---|
Texture | nil | The 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.
| Parameter | Type | Description |
|---|---|---|
what | string | "toggle", "next", "previous", "shuffle" or "repeat". |
media.seek#since 1.0
media.seek(seconds: number)Seeks within the track when can_seek is true.
| Parameter | Type | Description |
|---|---|---|
seconds | number | The position to jump to. |
MediaInfo#
What media.get() returns.
| Field | Type | Description |
|---|---|---|
available | boolean | The media session can be used. |
has_session | boolean | Something is registered as playing. |
title | string | Track title. |
artist | string | Artist. |
album | string | Album. |
app | string | The playing application. |
playing | boolean | Playing (not paused). |
can_toggle | boolean | Play/pause works. |
can_next | boolean | Next works. |
can_previous | boolean | Previous works. |
can_seek | boolean | Seeking works. |
shuffle | boolean | Shuffle is on. |
repeat | integer | Repeat mode. |
position | number | Seconds into the track. |
duration | number | Track length in seconds. |
track_key | string | An id that changes with the track. |
has_cover | boolean | A cover exists. |
cover_loading | boolean | The cover is still loading. |
accent | {r, g, b} | nil | A colour taken from the cover. |