AirPlay.V2.Player (AirPlay v0.4.2)

Copy Markdown View Source

Minimal AirPlay 2 file player.

This follows the audible airplay2-rs test_gptp sequence for HomePod-class receivers:

  • transient pair
  • SETUP phase 1
  • connect event channel
  • bind local control socket before SETUP phase 2
  • SETUP phase 2 with random shk
  • RECORD seq=0;rtptime=0
  • run BMCA-yield PTP and use the receiver clock for PT=87 sync
  • FLUSH seq=0;rtptime=0
  • send ALAC RTP with SSRC=0, sequence=0, timestamp=0

Summary

Functions

Play a local audio file to an AirPlay 2 receiver.

Set volume on a running AP2 player process.

Ask a running AP2 player process to stop.

Functions

play_file(host, path, opts \\ [])

@spec play_file(String.t(), String.t(), keyword()) :: {:ok, map()} | {:error, term()}

Play a local audio file to an AirPlay 2 receiver.

Options:

  • :port - RTSP port, defaults to 7000
  • :seconds - limit playback duration, useful for smoke tests
  • :volume - optional AirPlay volume, 0.0..1.0
  • :render_delay_ms - added to PT=87 sync timestamps, defaults to 0

set_volume(pid, volume)

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

Set volume on a running AP2 player process.

stop(pid)

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

Ask a running AP2 player process to stop.