I've got 3 .wav files that I'd like my users to be able to pick from.
I have then entered into a ComboBox, and selected like so.
Public ChosenSound As Object
--
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
If ComboBox1.SelectedItem = "Beep" Then
ComboBox1.Text = "Beep"
ChosenSound = My.Resources.beeps
PlayBackgroundSoundResource()
End If
If ComboBox1.SelectedItem = "Chime" Then
ComboBox1.Text = "Chime"
ChosenSound = My.Resources.chime
PlayBackgroundSoundResource()
End If
If ComboBox1.SelectedItem = "Chirp" Then
ComboBox1.Text = "Chirp"
ChosenSound = My.Resources.chirp
PlayBackgroundSoundResource()
End If
End Sub
--
Sub PlayBackgroundSoundResource()
Try
My.Computer.Audio.Play(ChosenSound, AudioPlayMode.Background)
Catch ex1 As Exception
MessageBox.Show(ex1.Message)
Return
End Try
End Sub
Each sound plays perfectly fine when selected through the ComboBox, but once the sound is played through other means, I.E an button press, I get the following error:
---------------------------
---------------------------
The wave header is corrupt.
---------------------------
OK
---------------------------
Here is the code for the button press:
Private Sub optionsBTNtestsound_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles optionsBTNtestsound.Click
PlayBackgroundSoundResource()
End Sub
Am I doing this all wrong? Why can my sound only play once selected by the ComboBox and not when called in any other way?