Hi all
I have encountered a problem when attempting to play a sound file immediately after loading it - the sound appears not to be played. However, if I introduce a "break" between the two lines, e.g. a message box, the sound is played. It also plays during debug.
This is the Sub:
Any help would be much appreciated.
I have encountered a problem when attempting to play a sound file immediately after loading it - the sound appears not to be played. However, if I introduce a "break" between the two lines, e.g. a message box, the sound is played. It also plays during debug.
This is the Sub:
B4X:
Sub ivSound_Click
Dim intSoundID As Int
Dim TaskID As String
Try
' Find out which panel is visible and get the task number
For Each v As View In Activity
If v Is Panel Then
Dim PanelTag As String
PanelTag = v.Tag
'Dim VisiblePanelID As String
If PanelTag.StartsWith("Task") Then
If v.Visible = True Then
TaskID = PanelTag
End If
End If
End If
Next
' Load the sound file
intSoundID = SP.Load(File.DirAssets, TaskID & ".mp3")
'Play the sound file
'Msgbox(intSoundID,"")
SP.Play(intSoundID, 1, 1, 1, 0, 1)
Catch
Msgbox(LastException.Message,"")
End Try
End Sub
Any help would be much appreciated.