rockbox/player

Queue-based player with native ReplayGain and Rockbox crossfade.

A Player owns a live audio output device and a background engine thread, so it only works where an output device exists. The handle is a NIF resource, freed by the BEAM garbage collector (which stops playback).

ReplayGain mode here uses the player values: 0 off, 1 track, 2 album. Crossfade mode: 0 off, 1 auto-skip, 2 manual-skip, 3 shuffle, 4 shuffle-or-manual, 5 always. Mix mode: 0 crossfade, 1 mix.

Types

Player configuration. sample_rate: 0 means the output device default.

pub type Config {
  Config(
    sample_rate: Int,
    buffer_seconds: Float,
    volume: Float,
    replaygain_mode: Int,
    replaygain_preamp_db: Float,
    replaygain_prevent_clipping: Bool,
    crossfade_mode: Int,
    fade_out_delay_ms: Int,
    fade_out_duration_ms: Int,
    fade_in_delay_ms: Int,
    fade_in_duration_ms: Int,
    mix_mode: Int,
  )
}

Constructors

  • Config(
      sample_rate: Int,
      buffer_seconds: Float,
      volume: Float,
      replaygain_mode: Int,
      replaygain_preamp_db: Float,
      replaygain_prevent_clipping: Bool,
      crossfade_mode: Int,
      fade_out_delay_ms: Int,
      fade_out_duration_ms: Int,
      fade_in_delay_ms: Int,
      fade_in_duration_ms: Int,
      mix_mode: Int,
    )

Opaque player handle (a NIF resource).

pub type Player

A snapshot of the player’s status.

pub type Status {
  Status(
    state: String,
    index: option.Option(Int),
    position_ms: Int,
    duration_ms: Int,
    queue_len: Int,
  )
}

Constructors

  • Status(
      state: String,
      index: option.Option(Int),
      position_ms: Int,
      duration_ms: Int,
      queue_len: Int,
    )

Values

pub fn default_config() -> Config

Rockbox-default configuration (device sample rate, no crossfade, ReplayGain off, full volume).

pub fn enqueue(player: Player, path: String) -> Nil
pub fn new() -> Player

Create a player on the default device with default settings.

pub fn next(player: Player) -> Nil
pub fn pause(player: Player) -> Nil
pub fn play(player: Player) -> Nil
pub fn previous(player: Player) -> Nil
pub fn sample_rate(player: Player) -> Int
pub fn seek_ms(player: Player, ms: Int) -> Nil
pub fn set_crossfade(
  player: Player,
  mode: Int,
  fade_out_delay_ms: Int,
  fade_out_duration_ms: Int,
  fade_in_delay_ms: Int,
  fade_in_duration_ms: Int,
  mix_mode: Int,
) -> Nil
pub fn set_queue(player: Player, paths: List(String)) -> Nil

Replace the queue with a list of file paths.

pub fn set_replaygain(
  player: Player,
  mode: Int,
  preamp_db: Float,
  prevent_clipping: Bool,
) -> Nil
pub fn set_volume(player: Player, volume: Float) -> Nil
pub fn skip_to(player: Player, index: Int) -> Nil
pub fn status(player: Player) -> Status

A snapshot of the player’s status.

pub fn stop(player: Player) -> Nil
pub fn toggle(player: Player) -> Nil
pub fn volume(player: Player) -> Float
pub fn with_config(c: Config) -> Player

Create a player with explicit configuration.

Search Document