Rockbox.Player (rockbox_ex_ffi v0.1.0)

Copy Markdown View Source

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.

Summary

Types

t()

Opaque player handle (a NIF resource).

Functions

Create a player on the default device with default settings.

Create a player with configuration overrides (see @default_config keys). sample_rate: 0 means the device default.

Replace the queue with a list of file paths.

A snapshot of the player's status as an atom-keyed map.

Types

t()

@opaque t()

Opaque player handle (a NIF resource).

Functions

enqueue(p, path)

@spec enqueue(t(), Path.t()) :: :ok

new()

@spec new() :: t() | nil

Create a player on the default device with default settings.

new(opts)

@spec new(keyword() | map()) :: t() | nil

Create a player with configuration overrides (see @default_config keys). sample_rate: 0 means the device default.

next(p)

@spec next(t()) :: :ok

pause(p)

@spec pause(t()) :: :ok

play(p)

@spec play(t()) :: :ok

previous(p)

@spec previous(t()) :: :ok

sample_rate(p)

@spec sample_rate(t()) :: non_neg_integer()

seek_ms(p, ms)

@spec seek_ms(t(), non_neg_integer()) :: :ok

set_crossfade(p, mode, fo_delay_ms, fo_dur_ms, fi_delay_ms, fi_dur_ms, mix_mode)

@spec set_crossfade(t(), 0..5, integer(), integer(), integer(), integer(), 0..1) ::
  :ok

set_queue(p, paths)

@spec set_queue(t(), [Path.t()]) :: :ok

Replace the queue with a list of file paths.

set_replaygain(p, mode, preamp_db, prevent_clipping)

@spec set_replaygain(t(), 0..2, number(), boolean()) :: :ok

set_volume(p, vol)

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

skip_to(p, index)

@spec skip_to(t(), non_neg_integer()) :: :ok

status(p)

@spec status(t()) :: map()

A snapshot of the player's status as an atom-keyed map.

stop(p)

@spec stop(t()) :: :ok

toggle(p)

@spec toggle(t()) :: :ok

volume(p)

@spec volume(t()) :: float()