Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
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.

Go Back   Vista Forums > Misc Newsgroups > .NET General

Vista - wav file played from resource is "scratchy"

Reply
 
Old 05-23-2008   #1 (permalink)
Logan


 
 

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 SpecsSystem Spec
Reply

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


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46