pub struct AudioPlayer { /* private fields */ }Expand description
Rust wrapper for Android audio player
Implementations§
Source§impl AudioPlayer
impl AudioPlayer
Sourcepub fn new(
env: JNIEnv<'_>,
context: &GlobalRef,
sample_rate: i32,
channel_config: i32,
audio_format: i32,
mode: i32,
) -> Result<Self, PlayerError>
pub fn new( env: JNIEnv<'_>, context: &GlobalRef, sample_rate: i32, channel_config: i32, audio_format: i32, mode: i32, ) -> Result<Self, PlayerError>
Create a new AudioPlayer instance
§Arguments
env- JNI environmentcontext- GlobalRef to context object (used to get the correct ClassLoader)sample_rate- Sample rate (e.g., 16000, 44100, 48000)channel_config- Channel configuration (use ChannelOutConfig constants)audio_format- Audio encoding format (use AudioEncoding constants)mode- Playback mode (use PlayerMode constants)
§Returns
Returns initialized AudioPlayer instance
§Examples
See the README.md for complete usage examples.
Sourcepub fn play(&self) -> Result<(), PlayerError>
pub fn play(&self) -> Result<(), PlayerError>
Start playback
Sourcepub fn stop(&self) -> Result<(), PlayerError>
pub fn stop(&self) -> Result<(), PlayerError>
Stop playback
Sourcepub fn pause(&self) -> Result<(), PlayerError>
pub fn pause(&self) -> Result<(), PlayerError>
Pause playback
Sourcepub fn flush(&self) -> Result<(), PlayerError>
pub fn flush(&self) -> Result<(), PlayerError>
Flush buffer
Sourcepub fn release(&self) -> Result<(), PlayerError>
pub fn release(&self) -> Result<(), PlayerError>
Release resources
Sourcepub fn get_sample_rate(&self) -> i32
pub fn get_sample_rate(&self) -> i32
Get sample rate
Sourcepub fn get_channel_count(&self) -> i32
pub fn get_channel_count(&self) -> i32
Get channel count
Sourcepub fn get_audio_format(&self) -> i32
pub fn get_audio_format(&self) -> i32
Get audio format
Sourcepub fn get_buffer_size(&self) -> Result<i32, PlayerError>
pub fn get_buffer_size(&self) -> Result<i32, PlayerError>
Get buffer size
Trait Implementations§
Auto Trait Implementations§
impl Freeze for AudioPlayer
impl RefUnwindSafe for AudioPlayer
impl Unpin for AudioPlayer
impl UnwindSafe for AudioPlayer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more