I have a method that returns the full path of a file and then getting a media player to play it, it doesn't work even if the string is hard coded the same as the method that returns a full path. I think it may have something to do with the URI but not quite sure.
private void PlayMusic()//method that creates media player
{
var Player = Utilities.GetMediaPlayer();
Player.Open(GetURI());
Player.Play();
}
private void btnBattleMusic_Click(object sender, EventArgs e)//gets the path
{
Full = Path.GetFullPath(@"C:Death.wav");
//MusicPath = Full.Replace(@"\\", @"\");
MusicPath = @"C:\Users\ser\Documents\Visual Studio 2015\Projects\DNDSoundboard\DNDSoundboard\bin\Debug\Sounds\BattleMusicWolfBlood.mp3";
PlayMusic();
}
private System.Uri GetURI()//method that gets the URI
{
return new System.Uri(MusicPath); //IF THIS IS CHANGED TO "Full" it doesn't work.. I run it but it has no errors pop up.
}
Thanks in advance for helping.
Full = Path.GetFullPath("C:BattleMusicWolfBlood.mp3");
After much playing around, I moved the sound into the Debug folder and it worked with the code above, previously I had it in another folder inside Debug under "Sounds".
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.