Playing sounds on Console - C#

后端 未结 3 1775
我在风中等你
我在风中等你 2021-01-03 11:09

I\'m writing a Console application on C# and I want to play a sound when I display texts continuously. This is what I\'ve done :

static SoundPlayer typewrite         


        
3条回答
  •  臣服心动
    2021-01-03 11:29

    If for example you have your sounds in the folder "Assets" then subfolder "SoundClips" do it like this.

    var soundLocation = Environment.CurrentDirectory + @"\Assets\SoundClips\";
    
    SoundPlayer player = new SoundPlayer
    {
        SoundLocation = soundLocation + "typewriter.wav",
    };
    

    Make sure you have the file properties set to:

    build action - Content

    copy to output directory - Copy if newer

提交回复
热议问题