rockbox/playback
Transport controls and “play this thing” shortcuts.
import rockbox
import rockbox/playback
let client = rockbox.connect(rockbox.new())
let _ = playback.play_track(client, "/Music/Miles Davis/Kind of Blue/01.flac")
let _ = playback.pause(client)
let _ = playback.next(client)
Types
Optional knobs accepted by every play_* shortcut.
Build one with play_options() and chain with_shuffle / with_position:
let opts =
playback.play_options()
|> playback.with_shuffle(True)
|> playback.with_position(2)
let _ = playback.play_album(client, "abc-123", opts)
pub opaque type PlayOptions
Values
pub fn current_track(
client: rockbox.Client,
) -> Result(option.Option(types.Track), error.Error)
The track currently loaded for playback (may not be playing). Returns
Ok(None) if no track is queued.
pub fn file_position(
client: rockbox.Client,
) -> Result(Int, error.Error)
Position of the audio file the codec is currently reading from, in bytes.
pub fn flush_and_reload(
client: rockbox.Client,
) -> Result(Nil, error.Error)
Flush the codec buffer and reload the queue from disk.
pub fn next(client: rockbox.Client) -> Result(Nil, error.Error)
Skip to the next track in the queue.
pub fn next_track(
client: rockbox.Client,
) -> Result(option.Option(types.Track), error.Error)
The track that will play after the current one finishes. Ok(None) if the
queue ends with the current track.
pub fn play(
client: rockbox.Client,
elapsed: Int,
offset: Int,
) -> Result(Nil, error.Error)
Start playback at elapsed ms with the codec offset set to offset bytes.
Pass 0, 0 to start from the beginning.
pub fn play_album(
client: rockbox.Client,
album_id: String,
options: PlayOptions,
) -> Result(Nil, error.Error)
Replace the queue with every track on an album and start playing.
pub fn play_all_tracks(
client: rockbox.Client,
options: PlayOptions,
) -> Result(Nil, error.Error)
Play the entire library.
pub fn play_artist(
client: rockbox.Client,
artist_id: String,
options: PlayOptions,
) -> Result(Nil, error.Error)
Replace the queue with every track an artist has and start playing.
pub fn play_directory(
client: rockbox.Client,
path: String,
recurse: Bool,
options: PlayOptions,
) -> Result(Nil, error.Error)
Queue and play every audio file in a directory.
pub fn play_liked_tracks(
client: rockbox.Client,
options: PlayOptions,
) -> Result(Nil, error.Error)
Play every liked track.
pub fn play_options() -> PlayOptions
Default play options — no shuffle, append at the end.
pub fn play_playlist(
client: rockbox.Client,
playlist_id: String,
options: PlayOptions,
) -> Result(Nil, error.Error)
Play a saved playlist by ID.
pub fn play_track(
client: rockbox.Client,
path: String,
) -> Result(Nil, error.Error)
Play a single file by absolute path.
pub fn previous(
client: rockbox.Client,
) -> Result(Nil, error.Error)
Go back to the previous track.
pub fn raw_status(
client: rockbox.Client,
) -> Result(Int, error.Error)
Raw numeric playback status as the firmware reports it.
pub fn resume(client: rockbox.Client) -> Result(Nil, error.Error)
Resume playback after a pause.
pub fn seek(
client: rockbox.Client,
position_ms: Int,
) -> Result(Nil, error.Error)
Seek the current track to an absolute position in milliseconds.
pub fn status(
client: rockbox.Client,
) -> Result(types.PlaybackStatus, error.Error)
Typed playback status (Stopped, Playing, Paused, …).
pub fn stop(client: rockbox.Client) -> Result(Nil, error.Error)
Stop playback and tear down the audio engine.
pub fn with_position(
opts: PlayOptions,
value: Int,
) -> PlayOptions
Set the queue position to start playback at.
pub fn with_shuffle(
opts: PlayOptions,
value: Bool,
) -> PlayOptions
Toggle shuffle for the resulting queue.