我有一个方法返回文件的完整路径,然后让媒体播放器播放它,即使字符串的硬编码与返回完整路径的方法相同,它也不起作用。我认为它可能与URI有关但不太确定。
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.
}
提前感谢您的帮助。
答案 0 :(得分:0)
Full = Path.GetFullPath(" C:BattleMusicWolfBlood.mp3");
经过多次游戏后,我将声音移动到Debug文件夹中,它使用了上面的代码,之前我已将它放在Debug内的另一个文件夹中" Sounds"。