AirPlay.V2.GroupSession (AirPlay v0.5.1)

Copy Markdown View Source

Persistent AirPlay 2 multi-room group session.

The group analogue of AirPlay.V2.Session: it pairs + sets up every receiver, starts one BMCA-yield PTP clock on the primary, sends SETPEERS, and then keeps that whole arrangement warm across tracks. Each play/3 flushes (continuing the shared RTP timeline) and streams one decode to every receiver, encrypting each packet with that receiver's stream key.

Same owner-notification contract as AirPlay.V2.Session:

  • {AirPlay.V2.GroupSession, :ended, play_gen} — current track finished
  • {AirPlay.V2.GroupSession, :error, play_gen, reason} — a track failed to start

Summary

Functions

Tear down the group session and close every receiver.

Open a persistent session to an AirPlay 2 receiver group.

Play (or skip to) a file on an open group session. Continues the RTP timeline.

Set the group volume (0.0..1.0) on every receiver.

Stop the current track but keep the group connection warm.

Functions

close(pid)

@spec close(pid()) :: :ok

Tear down the group session and close every receiver.

connect(receivers, opts \\ [])

@spec connect(
  [map()],
  keyword()
) :: {:ok, pid()} | {:error, term()}

Open a persistent session to an AirPlay 2 receiver group.

Receivers are maps with at least :host/"host" and optional :port/"port". Options mirror AirPlay.V2.Session.connect/2 (:owner, :render_delay_ms, :ptp_settle_ms, :connect_timeout_ms).

play(pid, path, opts \\ [])

@spec play(pid(), String.t(), keyword()) :: :ok

Play (or skip to) a file on an open group session. Continues the RTP timeline.

set_volume(pid, volume)

@spec set_volume(pid(), number()) :: :ok

Set the group volume (0.0..1.0) on every receiver.

stop(pid)

@spec stop(pid()) :: :ok

Stop the current track but keep the group connection warm.