![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | wav file played from resource is "scratchy" I have an application that plays short (2-5 seconds) sounds from resources at specific times. About 10% of the time the wav file will start playing fine and at some undetermined point during the playback it will play loud tones for the duration of the sound files normal time. I cannot figure out what actually causes it. I can click a different button and have another sound play fine out of the resource while the first sound is malfunctioning. It appears that the malfunctions are completely random. It only appears to occur when i play the sound from a resource, as i seem to be able to play sounds fine when i point them at the file on the harddrive instead of passing in the stream from the resource. The code is very simple. I have an overall setting that turns sounds on and off. Then a setting that allows the user to change the applause sound. If the path is empty or doesn't point to a valid sound file it will play the default from a resource public static void PlayApplause() { if (!PlaySound(Settings.Default.ApplauseSoundPath)) PlaySound(Resources.applausesmall_Sound); } public static bool PlaySound(Stream toPlay) { bool rVal = false; try { if (Settings.Default.PlaySounds) { SoundPlayer sp = new SoundPlayer(toPlay); sp.Load(); sp.Play(); rVal = true; } } catch { rVal = false; } return rVal; } public static bool PlaySound(string Path) { bool rVal = false; try { if (Settings.Default.PlaySounds && !string.IsNullOrEmpty(Path) && File.Exists(Path)) { SoundPlayer sp = new SoundPlayer(Path); sp.Load(); sp.Play(); rVal = true; } } catch { rVal = false; } return rVal; } |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| "Extensible Authentication Protocol" service gives "The system cannot find the file specified" error | Vista networking & sharing | |||
| Windows mail shuts down when "Insert" - "File Attachments" is sele | Vista mail | |||
| "you might not have permission to use this network resource" | Vista networking & sharing | |||
| Can a movie DVD image on the hard drive be "played"? | Vista General | |||
| Changing "mailto" protocol via registry--no "clients" file under HKEY_USERS | Vista mail | |||