Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Selecting sounds from Windows and playing them

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 to have a combobox where the user can select from the Windows stored sounds such as "critical stop", "critical beep" and so on. These are found in the "Control Panel" >> "Sounds and Alerts" section.

Is it also possible to have a play button to test the sounds out?

like image 613
Funky Avatar asked Mar 04 '11 11:03

Funky


People also ask

How do you play different Sounds from different outputs?

You can either right-click the speaker icon in your notification area, and then select “Open Sound Settings” or navigate to Settings > System > Sound. In the Sound settings, scroll down to the “Other Sound Options” section, and then click the “App Volume And Device Preferences” option.

How do I play Sounds on Windows?

Open File Explorer or Windows Explorer and navigate to the following path: C:\Windows\Media. Scroll down past the folders until you see the individual sounds. Each sound is saved as a WAV file, which means you can play it in Windows Media Player or a similar audio player.

How do I play sound files on Windows 10?

In Windows 10, open the Start menu, and scroll down to the "W" section to find Windows Media Player. Once it is running, select Open from the file menu, then browse to the location of the audio file. Alternatively, you can drag-and-drop the audio file onto Windows Media Player.


1 Answers

You do not require any API to play system sounds just write code like this:

// Plays the sound associated with the Asterisk system event.
System.Media.SystemSounds.Asterisk.Play();

The SystemSounds class contains the following predefined system sounds:

  • Asterisk
  • Beep
  • Exclamation
  • Hand
  • Question

All other sounds require you read the desired sound from the registry and play it with code like this:

SoundPlayer simpleSound = new SoundPlayer(@"c:\Path\To\Your\Wave\File.wav");
like image 114
Alex Essilfie Avatar answered Sep 18 '22 11:09

Alex Essilfie