Struct AudioResource
zaun_client::AudioResource · Struct
pub struct AudioResource { … }Something to play: Opus packets, from an Ogg Opus file or stream, from ffmpeg (any format it reads), or from the application.
Methods
Section titled “Methods”pub fn ogg<impl Read + Send + 'static>(reader: impl Read + Send + 'static) -> SelfAn Ogg Opus stream (.opus, or .ogg holding Opus), sent as it is.
ogg_file
Section titled “ogg_file”pub fn ogg_file<impl AsRef<Path>>(path: impl AsRef<Path>) -> Result<Self>An Ogg Opus file, sent as it is; titled with its file name.
Errors
Section titled “Errors”Error::Audio when the file cannot be opened.
opus_packets
Section titled “opus_packets”pub fn opus_packets<impl IntoIterator<Item = Vec<u8>, IntoIter : Send + 'static>>(packets: impl IntoIterator<Item = Vec<u8>, IntoIter = …>) -> SelfOpus packets the application made (each one 2.5 to 120 ms, as its TOC byte says).
ffmpeg_file
Section titled “ffmpeg_file”pub fn ffmpeg_file<impl AsRef<Path>>(path: impl AsRef<Path>, options: FfmpegOptions) -> Result<Self>Any audio file ffmpeg reads (mp3, flac, wav, m4a, a video’s sound…), transcoded to Opus.
Errors
Section titled “Errors”Error::Audio when the file is missing, an option is out of range, or ffmpeg is not
installed.
ffmpeg_url
Section titled “ffmpeg_url”pub fn ffmpeg_url(url: &str, options: FfmpegOptions) -> Result<Self>An http:// or https:// stream or file, fetched and transcoded by ffmpeg.
Errors
Section titled “Errors”Error::Audio for another scheme, an option out of range, or no ffmpeg.
ffmpeg_reader
Section titled “ffmpeg_reader”pub fn ffmpeg_reader<impl Read + Send + 'static>(reader: impl Read + Send + 'static, options: FfmpegOptions) -> Result<Self>Audio the application streams (another program’s output, a download), transcoded by ffmpeg as it arrives.
Errors
Section titled “Errors”Error::Audio for an option out of range, or no ffmpeg.
pub fn pcm<impl Read + Send + 'static>(reader: impl Read + Send + 'static, options: FfmpegOptions) -> Result<Self>Raw PCM the application makes (text to speech, a synthesiser): signed 16-bit little-endian samples, 48 kHz, two channels interleaved. Encoded to Opus by ffmpeg.
Errors
Section titled “Errors”Error::Audio for an option out of range, or no ffmpeg.
pub fn file<impl AsRef<Path>>(path: impl AsRef<Path>, options: FfmpegOptions) -> Result<Self>Any audio file: an Ogg Opus file is sent as it is (no ffmpeg, no quality lost, like
discord.js’s demuxProbe), anything else goes through ffmpeg. options apply only
when ffmpeg runs; a volume or seek asks for it even for Ogg Opus.
Errors
Section titled “Errors”As ogg_file and ffmpeg_file.
with_title
Section titled “with_title”pub fn with_title<impl Into<String>>(self, title: impl Into<String>) -> SelfNames the resource (the events carry it).
pub fn title(&self) -> Option<&str>The title, if any.
Trait implementations
Section titled “Trait implementations”Debug, Drop