我有一个返回文件完整路径然后让媒体播放器播放它的方法,即使字符串的硬编码与返回完整路径的方法相同,它也不起作用。我认为这可能与 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:UsersserDocumentsVisual Studio 2015ProjectsDNDSoundboardDNDSoundboardbinDebugSoundsBattleMusicWolfBlood.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.
}
提前感谢您的帮助。
full = Path.GetFullPath("C:BattleMusicWolfBlood.mp3");
经过多次播放,我将声音移动到 Debug 文件夹中,它与上面的代码一起工作,以前我把它放在"声音"下的调试中的另一个文件夹中。