Expand description
Builder pattern for configuring and constructing decoders.
This module provides a flexible builder API for creating decoders with custom settings. The builder allows configuring format hints, seeking behavior, byte length and other parameters that affect decoder behavior.
§Examples
use std::fs::File;
use rodio::Decoder;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let file = File::open("audio.mp3")?;
let len = file.metadata()?.len();
Decoder::builder()
.with_data(file)
.with_byte_len(len) // Enable seeking and duration calculation
.with_hint("mp3") // Optional format hint
.with_gapless(true) // Enable gapless playback
.build()?;
// Use the decoder...
Ok(())
}
§Settings
The following settings can be configured:
byte_len
- Total length of the input data in byteshint
- Format hint like “mp3”, “wav”, etcmime_type
- MIME type hint for container formatsseekable
- Whether seeking operations are enabledgapless
- Enable gapless playbackcoarse_seek
- Use faster but less precise seeking
Structs§
- Decoder
Builder - Builder for configuring and creating a decoder.
- Settings
- Audio decoder configuration settings. Support for these settings depends on the underlying decoder implementation. Currently, settings are only used by the Symphonia decoder.