Skip to main content

SoundProvider

Trait SoundProvider 

Source
pub trait SoundProvider {
    // Required methods
    fn play(&self, clip: &SoundClip);
    fn speak(&self, text: &str, language: &str);
    fn stop_speaking(&self);

    // Provided method
    fn speak_clip(&self, clip: &SoundClip) { ... }
}
Expand description

Plays sounds and speaks. Platform layers install one with crate::Ui::set_sound; until then, nothing is heard.

Required Methods§

Source

fn play(&self, clip: &SoundClip)

Starts clip, over whatever is already playing.

Source

fn speak(&self, text: &str, language: &str)

Says text with the system’s voice for language, such as pt-BR, in place of anything still being said.

Source

fn stop_speaking(&self)

Stops what is being said.

Provided Methods§

Source

fn speak_clip(&self, clip: &SoundClip)

Says a recording, in place of anything still being said, so that SoundProvider::stop_speaking stops it. By default it only plays.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§