pub struct AudioResource { /* private fields */ }Expand description
Something to play: Opus packets, from an Ogg Opus file or stream, from ffmpeg (any format it reads), or from the application.
Implementations§
Source§impl AudioResource
impl AudioResource
Sourcepub fn ogg(reader: impl Read + Send + 'static) -> Self
pub fn ogg(reader: impl Read + Send + 'static) -> Self
An Ogg Opus stream (.opus, or .ogg holding Opus), sent as it is.
Sourcepub fn ogg_file(path: impl AsRef<Path>) -> Result<Self>
pub fn ogg_file(path: impl AsRef<Path>) -> Result<Self>
An Ogg Opus file, sent as it is; titled with its file name.
§Errors
Error::Audio when the file cannot be opened.
Sourcepub fn opus_packets(
packets: impl IntoIterator<Item = Vec<u8>, IntoIter: Send + 'static>,
) -> Self
pub fn opus_packets( packets: impl IntoIterator<Item = Vec<u8>, IntoIter: Send + 'static>, ) -> Self
Opus packets the application made (each one 2.5 to 120 ms, as its TOC byte says).
Sourcepub fn ffmpeg_file(
path: impl AsRef<Path>,
options: FfmpegOptions,
) -> Result<Self>
pub fn ffmpeg_file( 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
Error::Audio when the file is missing, an option is out of range, or ffmpeg is not
installed.
Sourcepub fn ffmpeg_url(url: &str, options: FfmpegOptions) -> Result<Self>
pub fn ffmpeg_url(url: &str, options: FfmpegOptions) -> Result<Self>
An http:// or https:// stream or file, fetched and transcoded by ffmpeg.
§Errors
Error::Audio for another scheme, an option out of range, or no ffmpeg.
Sourcepub fn ffmpeg_reader(
reader: impl Read + Send + 'static,
options: FfmpegOptions,
) -> Result<Self>
pub fn ffmpeg_reader( 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
Error::Audio for an option out of range, or no ffmpeg.
Sourcepub fn pcm(
reader: impl Read + Send + 'static,
options: FfmpegOptions,
) -> Result<Self>
pub fn pcm( 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
Error::Audio for an option out of range, or no ffmpeg.
Sourcepub fn file(path: impl AsRef<Path>, options: FfmpegOptions) -> Result<Self>
pub fn file(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
As ogg_file and ffmpeg_file.
Sourcepub fn with_title(self, title: impl Into<String>) -> Self
pub fn with_title(self, title: impl Into<String>) -> Self
Names the resource (the events carry it).