use fyrox_resource::io::FsResourceIo;
use fyrox_sound::buffer::SoundBufferResourceExtension;
use fyrox_sound::{
buffer::{DataSource, SoundBufferResource},
context::SoundContext,
engine::SoundEngine,
futures::executor::block_on,
pool::Handle,
source::{SoundSource, SoundSourceBuilder, Status},
};
use std::{thread, time::Duration};
fn main() {
let engine = SoundEngine::new().unwrap();
let context = SoundContext::new();
engine.state().add_context(context.clone());
let waterfall_buffer = SoundBufferResource::new_streaming(
block_on(DataSource::from_file(
"examples/data/waterfall.ogg",
&FsResourceIo,
))
.unwrap(),
)
.unwrap();
let source = SoundSourceBuilder::new()
.with_buffer(waterfall_buffer)
.with_status(Status::Playing)
.with_looping(true)
.build()
.unwrap();
let _source_handle: Handle<SoundSource> = context.state().add_source(source);
thread::sleep(Duration::from_secs(30))
}