I have a series of ImageView elements in my application that should act as "buttons". I want the user to hear a "click" sound when they tap the ImageView, but no sound currently plays. Through some of my testing, I figured that I might want to play some custom sounds for each of the ImageView objects' click events.
I found some .wav files for what I wanted to hear, so I added the files to the project and added the following code elements:
And similar code for other buttons. I compiled it to my device, but I'm not getting any of the sounds to play. I'm not sure if I'm missing something, so any help would be great.
I found some .wav files for what I wanted to hear, so I added the files to the project and added the following code elements:
B4X:
Sub Globals
Dim wavWinner As MediaPlayer
Dim wavButton As MediaPlayer
Dim wavError As MediaPlayer
Dim wavEndGame As MediaPlayer
...
End Sub
Sub Activity_Create(FirstTime As Boolean)
wavButton.Initialize
wavButton.Looping = False
wavButton.Load(File.DirAssets, "button.wav")
wavWinner.Initialize
wavWinner.Looping = False
wavWinner.Load(File.DirAssets, "winner.wav")
wavError.Initialize
wavError.Looping = False
wavError.Load(File.DirAssets, "error.wav")
wavEndGame.Initialize
wavEndGame.Looping = False
wavEndGame.Load(File.DirAssets, "endgame.wav")
...
End Sub
Sub Button1_Click
wavButton.Play
...
End Sub
Sub Button2_Click
wavButton.Play
...
End Sub
Sub Button3_Click
wavButton.Play
...
End Sub