mirror of
https://github.com/csd4ni3l/soundboard.git
synced 2026-06-02 14:46:11 +02:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 07c0457701 | |||
| 58deb34135 |
+9
-15
@@ -228,37 +228,31 @@ fn update_ui_scale_factor_system(egui_context: Single<(&mut EguiContextSettings,
|
|||||||
fn play_sound(file_path: String, app_state: &mut AppState) {
|
fn play_sound(file_path: String, app_state: &mut AppState) {
|
||||||
let file = File::open(&file_path).unwrap();
|
let file = File::open(&file_path).unwrap();
|
||||||
let src = Decoder::new(BufReader::new(file)).unwrap();
|
let src = Decoder::new(BufReader::new(file)).unwrap();
|
||||||
let sink = Sink::connect_new(&app_state.sound_system.output_stream.mixer());
|
|
||||||
let length = src
|
let length = src
|
||||||
.total_duration()
|
.total_duration()
|
||||||
.expect("Could not get source duration")
|
.expect("Could not get source duration")
|
||||||
.as_secs_f32();
|
.as_secs_f32();
|
||||||
|
|
||||||
|
let sink = Sink::connect_new(&app_state.sound_system.output_stream.mixer());
|
||||||
sink.append(src);
|
sink.append(src);
|
||||||
sink.play();
|
sink.play();
|
||||||
|
|
||||||
|
let playing_sound = PlayingSound {
|
||||||
|
file_path: file_path.clone(),
|
||||||
|
length,
|
||||||
|
sink,
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
{
|
normal_sink: {
|
||||||
let file2 = File::open(&file_path).unwrap();
|
let file2 = File::open(&file_path).unwrap();
|
||||||
let src2 = Decoder::new(BufReader::new(file2)).unwrap();
|
let src2 = Decoder::new(BufReader::new(file2)).unwrap();
|
||||||
let normal_sink = Sink::connect_new(&app_state.sound_system.normal_output_stream.mixer());
|
let normal_sink = Sink::connect_new(&app_state.sound_system.normal_output_stream.mixer());
|
||||||
normal_sink.append(src2);
|
normal_sink.append(src2);
|
||||||
|
normal_sink.play();
|
||||||
app_state.currently_playing.push(PlayingSound {
|
|
||||||
file_path: file_path.clone(),
|
|
||||||
length,
|
|
||||||
sink,
|
|
||||||
normal_sink
|
normal_sink
|
||||||
});
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
app_state.currently_playing.push(PlayingSound {
|
app_state.currently_playing.push(playing_sound);
|
||||||
file_path: file_path.clone(),
|
|
||||||
length,
|
|
||||||
sink
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn ui_system(mut contexts: EguiContexts, mut app_state: ResMut<AppState>) -> Result {
|
fn ui_system(mut contexts: EguiContexts, mut app_state: ResMut<AppState>) -> Result {
|
||||||
|
|||||||
Reference in New Issue
Block a user