Add play_music call to audiofrontend

This commit is contained in:
Louis Pearson 2019-08-31 15:39:40 -06:00
parent 132d108086
commit 41cd20aaf8
3 changed files with 21 additions and 3 deletions

View File

@ -29,7 +29,7 @@ impl Channel {
sink,
audio_type: AudioType::Music,
state: ChannelState::Playing,
fader: Fader::fade_in(0.25),
fader: Fader::fade_in(0.0),
}
}

View File

@ -74,7 +74,25 @@ impl AudioFrontend {
if let Some(device) = &self.audio_device {
let sink = SpatialSink::new(device, [0.0, 0.0, 0.0], LEFT_EAR, RIGHT_EAR);
let file = assets::load_file(&sound, &["wav", "ogg"]).unwrap();
let file = assets::load_file(&sound, &["wav"]).unwrap();
let sound = Decoder::new(file).unwrap();
sink.append(sound);
self.channels.push(Channel::sfx(id, sink));
}
id
}
pub fn play_music(&mut self, sound: String) -> usize {
let id = self.next_channel_id;
self.next_channel_id += 1;
if let Some(device) = &self.audio_device {
let sink = SpatialSink::new(device, [0.0, 0.0, 0.0], LEFT_EAR, RIGHT_EAR);
let file = assets::load_file(&sound, &["ogg"]).unwrap();
let sound = Decoder::new(file).unwrap();
sink.append(sound);

View File

@ -34,7 +34,7 @@ impl PlayState for MainMenuState {
// Used for client creation.
let mut client_init: Option<ClientInit> = None;
let music = global_state.audio.play_sound("voxygen.audio.soundtrack.veloren_title_tune-3".to_string());
let music = global_state.audio.play_music("voxygen.audio.soundtrack.veloren_title_tune-3".to_string());
global_state.audio.stop_channel(music, Fader::fade_out(10.0));
loop {