Selecting sounds from Windows and playing them

前端 未结 3 1147
说谎
说谎 2021-02-19 16:01

I have a WinForms app. This app has a Preferences section where the user will be able to select which sounds are played when an alert is being displayed.

Is it possible

3条回答
  •  旧巷少年郎
    2021-02-19 16:43

    Sure! All the sounds you're looking for are available through the System.Media.SystemSounds class, where they are exposed as public properties corresponding to the event types that trigger the sounds.

    Additionally, objects of the SystemSound class provide a Play method that you can call to play that sound asynchronously.

    So for example, to play the "Critical Stop" sound, you would simply write the following code:

    System.Media.SystemSounds.Hand.Play();
    

提交回复
热议问题