1use rg3d_sound::engine::SoundEngine;
2use rg3d_sound::futures::executor::block_on;
3use rg3d_sound::{
4 buffer::{DataSource, SoundBufferResource},
5 context::SoundContext,
6 pool::Handle,
7 source::{generic::GenericSourceBuilder, SoundSource, Status},
8};
9use std::{thread, time::Duration};
10
11fn main() {
12 let engine = SoundEngine::new();
14
15 let context = SoundContext::new();
17
18 engine.lock().unwrap().add_context(context.clone());
19
20 let waterfall_buffer = SoundBufferResource::new_streaming(
22 block_on(DataSource::from_file("examples/data/waterfall.ogg")).unwrap(),
23 )
24 .unwrap();
25
26 let source = GenericSourceBuilder::new()
28 .with_buffer(waterfall_buffer)
29 .with_status(Status::Playing)
30 .with_looping(true)
31 .build_source()
32 .unwrap();
33
34 let _source_handle: Handle<SoundSource> = context.state().add_source(source);
37
38 thread::sleep(Duration::from_secs(30))
39}