Ok not sure about the try block is there tbh I was using an XACT tutorial for this.
#Region "Imports"
Imports Microsoft.Xna.Framework
Imports Microsoft.Xna.Framework.Audio
#End Region
Module Audio
#Region "Objects/Variables"
Public Cue As Cue
Public SoundBank As SoundBank
Public AudioEngine As AudioEngine
Public WaveBank As WaveBank
#End Region
Public Sub PlaySound(ByVal CueName As String)
If Game.SoundEnabled = True Then
Try
Cue = SoundBank.GetCue(CueName) 'Get Sound File From Sound Bank'
Cue.Play() 'Play Sound File'
Catch ex As Exception
End Try
End If
End Sub
Public Sub StopSound()
Try
Cue.Stop(AudioStopOptions.Immediate) 'Stop Sound Immediatly'
Catch ex As Exception
End Try
End Sub
Public Sub InitilizeSoundEngine()
'Initialize Sound Objects'
AudioEngine = New AudioEngine("..\..\Audio\Game Audio.xgs")
WaveBank = New WaveBank(AudioEngine, "..\..\Audio\Wave Bank.xwb")
SoundBank = New SoundBank(AudioEngine, "..\..\Audio\Sound Bank.xsb")
End Sub
Public Sub DisposeEngine()
'Dispose Of Objects If Required'
AudioEngine.Dispose()
WaveBank.Dispose()
SoundBank.Dispose()
End Sub
Public Sub UpdateEngine()
'Update The Engine/Should Be Called As Often As Possible'
AudioEngine.Update()
End Sub
End Module
Here is how I am getting the sound to play:
PlaySound("Back" & CurrentBackSound)
And here is where I am trying to stop it:
Game.PreviousBackSound = Game.CurrentBackSound
Game.CurrentBackSound = GenBackSoundNo(Game.PreviousBackSound)
StopSound()
PlaySound("Back" & Game.CurrentBackSound)