Mediaplayer didn't work for me, so I moved to a simple test project (C# Console App). I added my .mp3 file to the project like this:
- Right click project name (test) in solution explorer
- add folder resources
- Right click the resources folder in solution explorer
- Add my warn.mp3 file
- left click the warn.mp3 file
- Changed Build Action to Resource in the properties window.
Sadly, this code doesnt work:
namespace test
{
class Program
{
public static void Main(string[] args)
{
MediaPlayer player = new MediaPlayer();
player.Open(new Uri("resources/warn.mp3", UriKind.Relative));
player.Play();
Console.ReadKey();
}
}
}
However, this one does:
namespace test
{
class Program
{
public static void Main(string[] args)
{
MediaPlayer player = new MediaPlayer();
player.Open(new Uri("C:\\Users\\Krepsy3\\Documents\\Programs\\OOP\\test\\test\\resources\\warn.mp3", UriKind.Absolute));
player.Play();
Console.ReadKey();
}
}
}
Any idea about what is wrong?