Answered by:
sound file only plays once

Question
-
I am trying to include an explosion sound with an explosion on the screen. The explosion is in a sub routine and I used the Sound.Play (soundfile) after creating the filepath variable with: soundfile="C:\Small basic\typing\expsound.wav"
It plays the sound the first time the sub is called, but not the subsequent times. If I use the PlayAndWait command, it DOES play every time the sub routine is called, but of course it waits until the sound has played all the way through before proceeding. How can I get it to play the sound file every time the subroutine is called.
The TextWindow is for debugging and won't be part of the actual program
Thanks
DanHere is the text
'random explosion
'assign random colors to explosion center
For n=1 to 10
expcolor[n]= GraphicsWindow.GetRandomColor ()
Endforsoundfile="C:\Small basic\typing\expsound.wav"w=1500
h=1000
cx=250
cy=250
expsize=150
TextWindow.Top = 1
TextWindow.Left = 600
'for now it's black, but eventually paste in a space picture
GraphicsWindow.BackgroundColor ="Black"
GraphicsWindow.Top = 1
GraphicsWindow.Left = 1
GraphicsWindow.Height = h
GraphicsWindow.Width = w
For m=1 to 50
cx=Math.GetRandomNumber (1300)+150
cy=Math.GetRandomNumber (650)+150
explosion()
Program.Delay (1000)
Endfor
Sub explosion
'GraphicsWindow.BrushColor ="White"
For n=2 To 10
'there are 10 colors assigned expcolor from 1 to 10
GraphicsWindow.BrushColor = expcolor[n]
GraphicsWindow.FillEllipse (cx-(n/2),cy-(n/2),n,n)
Program.Delay (n*5)
EndFor
GraphicsWindow.PenWidth = 1
For n=5 To expsize
xout[n]=Math.GetRandomNumber (n)-(n/2)
yout[n]=Math.GetRandomNumber (n)-(n/2)
GraphicsWindow.PenColor = GraphicsWindow.GetRandomColor ()
' Program.Delay (5)
' GraphicsWindow.SetPixel (cx+xout[n],cy+yout[n],GraphicsWindow.GetRandomColor())
GraphicsWindow.SetPixel (cx+xout[n],cy+yout[n],"White")
GraphicsWindow.DrawLine (cx,cy,cx+xout[n],cy+yout[n])
EndFor
Sound.Play(soundfile)
'Program.Delay (300)
'erase explosion
GraphicsWindow.PenColor = "Black"
GraphicsWindow.PenWidth = 3
For n=5 To expsize
GraphicsWindow.DrawLine (cx,cy,cx+xout[n],cy+yout[n])
GraphicsWindow.SetPixel (cx+xout[n],cy+yout[n],"Black")
EndFor
EndSub
Tuesday, September 18, 2018 6:18 PM
Answers
-
Try calling a Sound.Stop(soundfile) before Sound.Play(soundfile). This resets the sound.
... Sound.Stop(soundfile) Sound.Play(soundfile) ...
- Marked as answer by Rizdek Wednesday, September 19, 2018 9:43 AM
Tuesday, September 18, 2018 6:41 PM
All replies
-
Try calling a Sound.Stop(soundfile) before Sound.Play(soundfile). This resets the sound.
... Sound.Stop(soundfile) Sound.Play(soundfile) ...
- Marked as answer by Rizdek Wednesday, September 19, 2018 9:43 AM
Tuesday, September 18, 2018 6:41 PM -