![](/img/trans.png)
[英]Playing Windows System Sounds with System.Media.SoundPlayer
[英]System.Media.SoundPlayer not playing default nor other sounds
我使用Jetbrains rider作为IDE,并使用C#进行编码; 当我试图编译SoundPlayer类时,我没有声音也没有默认声音。 我的代码如下:
public static void Main(string[] args) {
const string introSongLocation =
@"/Users/niller/DragonBallZ_GameFolder/Sounds/introToGame.wav";
var sound = new System.Media.SoundPlayer(introSongLocation);
sound.Load();
sound.Play();
System.Console.WriteLine(sound.IsLoadCompleted);
System.Console.WriteLine(sound.SoundLocation);
System.Console.ReadLine();
}
Output to terminal:
true
/Users/niller/DragonBallZ_GameFolder/Sounds/introToGame.wav
正如你可以在下面的代码告诉,如果声音很可能加载我检查,但在其他方面,如果它不是SoundPlayer.Play()方法将发挥默认的声音,如解释的 。
因此我问:
仅提供wav声音文件的路径,然后将其加载,还是将wav文件放入我的解决方案文件夹中还不够吗? 到目前为止,似乎一切都没有。
解:
我使用的是MacBook,而该库仅适用于Windows和Linux。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.