Screeching Audio

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
<div style="color:Black;background-color:White; <pre>
<span style="color:Blue; Imports System.Media
<span style="color:Blue; Imports System.Resources

<span style="color:Blue; Public <span style="color:Blue; Class Form10

<span style="color:Blue; Public <span style="color:Blue; Sub PlaySound(<span style="color:Blue; ByVal SoundNum <span style="color:Blue; As <span style="color:Blue; Integer)

<span style="color:Blue; If SoundNum = 1 <span style="color:Blue; Then

Randomize()

<span style="color:Blue; Dim SndRotate <span style="color:Blue; As <span style="color:Blue; Integer = <span style="color:Blue; CInt(Int((6 * Rnd()) + 1))

<span style="color:Blue; If SndRotate = 1 <span style="color:Blue; Then <span style="color:Blue; My.Computer.Audio.Play(<span style="color:Blue; My.Resources.SIREN1, AudioPlayMode.Background)
<span style="color:Blue; If SndRotate = 2 <span style="color:Blue; Then <span style="color:Blue; My.Computer.Audio.Play(<span style="color:Blue; My.Resources.FUNNYENG, AudioPlayMode.Background)
<span style="color:Blue; If SndRotate = 3 <span style="color:Blue; Then <span style="color:Blue; My.Computer.Audio.Play(<span style="color:Blue; My.Resources.HURRICAN, AudioPlayMode.Background)
<span style="color:Blue; If SndRotate = 4 <span style="color:Blue; Then <span style="color:Blue; My.Computer.Audio.Play(<span style="color:Blue; My.Resources.LOGOSTIN, AudioPlayMode.Background)
<span style="color:Blue; If SndRotate = 5 <span style="color:Blue; Then <span style="color:Blue; My.Computer.Audio.Play(<span style="color:Blue; My.Resources.OCEANSEA, AudioPlayMode.Background)
<span style="color:Blue; If SndRotate = 6 <span style="color:Blue; Then <span style="color:Blue; My.Computer.Audio.Play(<span style="color:Blue; My.Resources.chimes, AudioPlayMode.Background)

<span style="color:Blue; End <span style="color:Blue; If

<span style="color:Blue; If SoundNum = 2 <span style="color:Blue; Then <span style="color:Blue; My.Computer.Audio.Play(<span style="color:Blue; My.Resources.Click_1, AudioPlayMode.WaitToComplete)
<span style="color:Blue; If SoundNum = 3 <span style="color:Blue; Then <span style="color:Blue; My.Computer.Audio.Play(<span style="color:Blue; My.Resources.Click_2, AudioPlayMode.WaitToComplete)
<span style="color:Blue; If SoundNum = 4 <span style="color:Blue; Then <span style="color:Blue; My.Computer.Audio.Play(<span style="color:Blue; My.Resources.Auto_destruct, AudioPlayMode.WaitToComplete)

<span style="color:Blue; End <span style="color:Blue; Sub


<span style="color:Blue; End <span style="color:Blue; Class
[/code]
<br/>
First let me tell you that on both of my developement Windows 7 machines I dont have this problem, however; on the deploy machine which runs Windows XP I do. The problem is that when I call the form below "Form10.PlaySound(1)" prior to my "OpenFileDialog1.ShowDialog()"
in Form3, when the sound plays, 9 out of 10 times the sound screeches through the speakers vs playing normally. How can I stop this from happening? I need the sounds to play in the background as they are about 4 seconds in length.
Ive tried placing the two "Imports" into the code even though I dont believe they are needed to try and solve this but no joy.
Thanks, rmcabc <hr class="sig RMCABC

View the full article
 
Back
Top