| Others infos about System.Media namespace and embedded sounds in a resource file. In a recent message I have dealt PlaySound method using InteropService. This method work with a path and this is a source of various problems: - You must specify a full or relative path and include in your dir app all sounds. - Users can delete files! You have a similar problem if your use PlaySound with a stream also. So, is good idea to insert your sounds in a Resources File like this: 1. Add \'New Item\' in your project. 2. Select \'Resource File\'. 3. Add all your sounds here. N.B. Set all wav files added like \'Embedded Resources\' in \'Build Action\' option in \'Properties Window\'. Now you can play all sounds like this: using System.Media; ... SoundPlayer snd_player = new SoundPlayer(\'RESOURCE_FILE_NAME\'.\'wav_name\'); snd_player.Play(); \'wav_name\' is one wave added to your resource file that appears like Resource File public global variable. \'Play()\' method play a wave in asynchronous mode, but you can play it in synchronous mode using \'PlaySync()\' method. -- Enjoy your sounds! :) |