Expand description
Decodes audio files using ffmpeg bindings
Create a Decoder by supplying a Path to an audio file. Decoder
implies Iterator where each iteration returns a single i16 signed 16bit sample.
Also implements rodio’s Source trait, where
the Decoder can be supplied as a sink source for playback.
§Features Flags
rodio_sourceto enable rodio’sSourcetrait
§Example as Rodio Source
use rodio::Sink;
use std::path::PathBuf;
fn play_file(input: PathBuf) -> Result<(), Error> {
let decoder = ffmpeg_decoder::Decoder::open(&input)?;
let device = rodio::default_output_device().unwrap();
let sink = Sink::new(&device);
sink.append(decoder);
sink.play();
sink.sleep_until_end();
Ok(())
}