mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Add play_music call to audiofrontend
This commit is contained in:
parent
132d108086
commit
41cd20aaf8
@ -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),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user