From d038cd9503af70e14e5021e69b51e010715e94c8 Mon Sep 17 00:00:00 2001 From: "NBTEMP\\bib" Date: Thu, 3 Sep 2026 11:31:57 +0200 Subject: [PATCH] Sound test --- Casino/Audioplayer.cs | 31 +++++++++++++++++++++++++++++++ Casino/Database.cs | 24 ++++++++++++++++++++++++ Casino/MainWindow.xaml | 1 + Casino/MainWindow.xaml.cs | 13 +++++++++++-- Casino/Slot System.cs | 3 +++ Casino/Slots.xaml.cs | 39 +++++++++++++++++++++++---------------- 6 files changed, 93 insertions(+), 18 deletions(-) create mode 100644 Casino/Audioplayer.cs diff --git a/Casino/Audioplayer.cs b/Casino/Audioplayer.cs new file mode 100644 index 0000000..715377c --- /dev/null +++ b/Casino/Audioplayer.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Media; +using System.Windows.Shapes; + +namespace Casino +{ + class Audioplayer + { + private readonly MediaPlayer player = new MediaPlayer(); + + public void Play(byte[] audioBlob) + { + string tempFile = System.IO.Path.Combine( + System.IO.Path.GetTempPath(), + Guid.NewGuid() + ".mp3"); + + + + File.WriteAllBytes(tempFile, audioBlob); + + player.Open(new Uri(tempFile)); + player.Play(); + } + + } +} diff --git a/Casino/Database.cs b/Casino/Database.cs index 3df5968..53201de 100644 --- a/Casino/Database.cs +++ b/Casino/Database.cs @@ -80,5 +80,29 @@ namespace Casino return imageBytes; } + + public byte[] GetSound(int id) + { + byte[] soundBytes = null; + + using (MySqlConnection conn = new MySqlConnection(myConnectionString)) + { + conn.Open(); + using (MySqlCommand cmd = new MySqlCommand("SELECT sound FROM Sounds WHERE id = @id",conn)) + { + cmd.Parameters.AddWithValue("@id", id); + + using (MySqlDataReader reader = cmd.ExecuteReader()) + { + if (reader.Read()) + { + soundBytes = (byte[])reader["sound"]; + } + } + } + } + + return soundBytes; + } } } diff --git a/Casino/MainWindow.xaml b/Casino/MainWindow.xaml index dbc65a3..013ee40 100644 --- a/Casino/MainWindow.xaml +++ b/Casino/MainWindow.xaml @@ -8,6 +8,7 @@ Title="MainWindow" Height="450" Width="800">