Skip to main content
Version: 2.5.x (dev)

Seeking in liquidsoap

Liquidsoap can seek within sources! Not all sources support seeking though: currently, they are mostly file-based sources such as request.queue, playlist, request.dynamic, etc.

The basic function to seek within a source is source.seek. It has the following type:

(source('a),float)->float

The parameters are:

  • The source to seek.
  • The duration in seconds to seek from current position.

The function returns the duration actually seeked.

Please note that seeking is done to a position relative to the current position. For instance, source.seek(s,3.) will seek 3 seconds forward in source s and source.seek(s,(-4.)) will seek 4 seconds backward.

Since seeking is currently only supported by request-based sources, it is recommended to hook the function as close as possible to the original source. Here is an example that implements a server/telnet seek function:

seek-telnet.liq
# A playlist source
s = playlist("/path/to/music")

# The server seeking function
def seek(t) =
t = float_of_string(default=0., t)
log(
"Seeking #{t} sec"
)
ret = source.seek(s, t)
"Seeked #{ret} seconds."
end

# Register the function
server.register(
namespace=source.id(s),
description="Seek to a relative position in source #{source.id(s)}",
usage="seek <duration>",
"seek",
seek
)

Cue points​

Request-based sources also support cue points, which cut the beginning and end of each track. The decoder applies the cue-in point by seeking in the file when it opens it, so cue points work with the same sources as source.seek. See cue points for how to set them.