Snapcast.Listener behaviour (Snapcast v0.1.1)

Copy Markdown View Source

Behaviour for receiving Snapcast.Server lifecycle events.

Configure with config :snapcast, listener: MyApp.SnapcastListener (or pass listener: when starting Snapcast.Server). All callbacks are optional; any not implemented are treated as no-ops. The server invokes them in its own process and rescues exceptions, so a misbehaving listener cannot take the server down.

The endpoint term is whatever the caller passed as :endpoint to Snapcast.play/3 — it is opaque to the server and echoed back unchanged.

Summary

Callbacks

A snapclient connected or disconnected (the client list changed).

The active source finished (reached its duration or end of stream).

Periodic playback progress for the active source, in milliseconds.

Callbacks

clients_changed()

(optional)
@callback clients_changed() :: any()

A snapclient connected or disconnected (the client list changed).

ended(endpoint)

(optional)
@callback ended(endpoint :: term()) :: any()

The active source finished (reached its duration or end of stream).

progress(endpoint, position_ms)

(optional)
@callback progress(endpoint :: term(), position_ms :: non_neg_integer()) :: any()

Periodic playback progress for the active source, in milliseconds.