add Programmyday form github

This commit is contained in:
Ruben Kallinich
2024-07-25 15:47:46 +02:00
parent 09c8eab938
commit 7362c3d7ce
132 changed files with 3669 additions and 0 deletions

View File

@@ -0,0 +1,55 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.NetworkInformation;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
namespace AudioPlayer
{
internal class AudioPlayer
{
private int id;
private AudioFile[] player;
private Random rnd = new Random();
public AudioPlayer(int cnt)
{
//this.id = id;
this.player = new AudioFile[cnt];
}
public void AddFile(AudioFile file)
{
for (int i = 0; i < player.Length; i++)
{
if (player[i] is null)
{
this.player[i] = file;
break;
}
}
}
public void RemoveFile(int id)
{
if (id >= 0 && id < player.Length)
{
player[id] = null;
}
}
public void Play(AudioFile file)
{
file.Play();
}
public void PlayAll()
{
player = player.OrderBy(i => rnd.Next(player.Length)).ToArray();
for (int i = 0; i < player.Length; i++)
{
if (player[i] is not null)
{
player[i].Play();
}
}
}
}
}