bookclerk_player_api::tracks
How long each audio file of an item plays, for the track list apps seek across.
The playback core knows each file's size and, once probed, its average bitrate; the catalog knows the whole runtime to the minute. Apps need each track's start and duration in seconds, so a file's duration comes from its bitrate when every file has one, and otherwise from its share of the bytes of the whole runtime.
| Item | Kind | Summary |
|---|---|---|
TrackSize |
struct | One file to time: its size and its probed average bitrate. |
track_durations_ms |
function | Each track's duration in milliseconds, in order. |
track_starts_ms |
function | Each track's start in milliseconds: the sum of the durations before it. |
pub struct TrackSize {
pub bytes: u64,
pub bitrate_kbps: Option<u32>,
}
One file to time: its size and its probed average bitrate.
Fields
bytes: Size in bytes.bitrate_kbps: Average bitrate in kilobits per second, when probed (0counts as not probed).
Implements: Clone, Copy, Debug, Eq, PartialEq
pub fn track_durations_ms(tracks: &[TrackSize], runtime_ms: Option<u64>) -> Vec<u64>
Each track's duration in milliseconds, in order.
tracks- The files in play order.runtime_ms- The whole runtime the catalog states, if known.
From the bitrates when every file has one; else each file's share of
the bytes of runtime_ms; else zeros. Each value is at most
MAX_MS, and the shares add up to the runtime (the last track takes
the remainder).
pub fn track_starts_ms(durations_ms: &[u64]) -> Vec<u64>
Each track's start in milliseconds: the sum of the durations before it.
durations_ms- The durations, in order.
Generated from crates/bookclerk-player-api at main · View as Markdown