Music Player Hinzugefügt
This commit is contained in:
+25
-1
@@ -13,7 +13,7 @@ namespace Casino
|
|||||||
{
|
{
|
||||||
private readonly MediaPlayer player = new MediaPlayer();
|
private readonly MediaPlayer player = new MediaPlayer();
|
||||||
|
|
||||||
public void Play(byte[] audioBlob)
|
public void PlaySound(byte[] audioBlob)
|
||||||
{
|
{
|
||||||
string tempFile = System.IO.Path.Combine(
|
string tempFile = System.IO.Path.Combine(
|
||||||
System.IO.Path.GetTempPath(),
|
System.IO.Path.GetTempPath(),
|
||||||
@@ -27,5 +27,29 @@ namespace Casino
|
|||||||
player.Play();
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,13 +26,11 @@ namespace Casino
|
|||||||
public Slots()
|
public Slots()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
Slot_System sys = new Slot_System();
|
|
||||||
sys.roll();
|
|
||||||
while (sys.getFertig())
|
|
||||||
{
|
|
||||||
|
|
||||||
LoadCard(8);
|
LoadCard(8);
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
private void LoadCard(int Bild)
|
private void LoadCard(int Bild)
|
||||||
@@ -40,7 +38,7 @@ namespace Casino
|
|||||||
Database db = new Database();
|
Database db = new Database();
|
||||||
byte[] img = db.GetCardImage(Bild);//2-10
|
byte[] img = db.GetCardImage(Bild);//2-10
|
||||||
|
|
||||||
kartenBild.Source = ByteArrayToImage(img);
|
Bild_11.Source = ByteArrayToImage(img);
|
||||||
}
|
}
|
||||||
|
|
||||||
private BitmapImage ByteArrayToImage(byte[] bytes)
|
private BitmapImage ByteArrayToImage(byte[] bytes)
|
||||||
|
|||||||
Reference in New Issue
Block a user