diff --git a/Casino/Audioplayer.cs b/Casino/Audioplayer.cs index 715377c..41023a3 100644 --- a/Casino/Audioplayer.cs +++ b/Casino/Audioplayer.cs @@ -13,7 +13,7 @@ namespace Casino { private readonly MediaPlayer player = new MediaPlayer(); - public void Play(byte[] audioBlob) + public void PlaySound(byte[] audioBlob) { string tempFile = System.IO.Path.Combine( System.IO.Path.GetTempPath(), @@ -26,6 +26,30 @@ namespace Casino player.Open(new Uri(tempFile)); player.Play(); } - + + private bool isPlaying = false; + private readonly MediaPlayer musicPlayer = new(); + + public void PlayMusic(byte[] audioBlob) + { + if (isPlaying) + return; + + isPlaying = true; + + string tempFile = System.IO.Path.Combine( + System.IO.Path.GetTempPath(), + Guid.NewGuid() + ".mp3"); + + System.IO.File.WriteAllBytes(tempFile, audioBlob); + + musicPlayer.MediaEnded += (s, e) => + { + isPlaying = false; + }; + + musicPlayer.Open(new Uri(tempFile)); + musicPlayer.Play(); + } } } diff --git a/Casino/Slots.xaml.cs b/Casino/Slots.xaml.cs index 2365f9d..2340c29 100644 --- a/Casino/Slots.xaml.cs +++ b/Casino/Slots.xaml.cs @@ -26,7 +26,7 @@ namespace Casino public Slots() { InitializeComponent(); - + LoadCard(8); @@ -38,7 +38,7 @@ namespace Casino Database db = new Database(); byte[] img = db.GetCardImage(Bild);//2-10 - Bild_21.Source = ByteArrayToImage(img); + Bild_11.Source = ByteArrayToImage(img); } private BitmapImage ByteArrayToImage(byte[] bytes)