Skip to content

Daniel-Liu-c0deb0t/replit_audio

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

replit_audio

Rust library for playing audio in repl.it.

Usage

Add

replit_audio = "0.1.0"

to your Cargo.toml file. This crate is available on crates.io.

Documentation is available on docs.rs.

You can view an example on repl.it. Tests should be ran on repl.it.

To play an audio file, create an Audio instance using the AudioBuilder:

let audio = AudioBuilder::new(&AudioType::File { file: FileType::Wav, path: "audio.wav".to_string() })
    .volume(1.0)
    .does_loop(true)
    .loop_count(-1)
    .build()
    .unwrap();

Then, you can obtain certain properties of the audio you played:

audio.get_duration().unwrap();
audio.get_remaining().unwrap();
audio.get_start_time().unwrap();
audio.get_end_time().unwrap();
audio.is_paused().unwrap();
// etc.

You can also play a tone:

let mut audio = AudioBuilder::new(&AudioType::Tone { tone: ToneType::Square, pitch: 440.0, duration: 2.0 })
    .build()
    .unwrap();

It is possible to update a playing audio instance:

audio.update(&AudioUpdate { volume: 0.1, paused: false, does_loop: false, loop_count: -1 }).unwrap();

License

MIT

About

Rust library for playing audio in repl.it.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages