I am queueing several mp3 files (very short files) to play in a service. If the mp3 file does not exist, then I have the service "speak" the alternate text within the service.
In my main app, I have an array of file names that as I need the "noise", I add the filename of the mp3 file and alternate text to the array. I then startservice(TTSservice).
TTSservice plays the first file in the queue and if there are more, then it plays them until the queue is empty.
Within my main program I call a sub that adds the file to the queue and then does the startservice.
It all works very well, but when I debug my program (both under 1.8 and 1.9 version of b4a), i can step through to the call to the sub (where the service is started) and then the debugger either never returns or returns past many breakpoints (doesn't stop at the next break).
Any ideas? BTW, I call startservice for every time i add a file to the queue.
Thanks
Main program:
MediaQueue(MediaPointer).Vox = Vox
MediaQueue(MediaPointer).VoxFldr = VoxFldr
MediaQueue(MediaPointer).Alternate = Alternate
MediaQueue(MediaPointer).Wait = DoWait
MediaPointer = MediaPointer + 1
StartService(TTSService)
Service:
Sub Service_Create
TTSReady=False
If TTS1.IsInitialized = False Then
TTS1.Initialize("TTS1")
MediaPlayer1.Initialize2("MediaPlayer1")
End If
TTS_Settings
Main.MediaServiceIsRunning = True
End Sub
Sub Service_Start
If Main.MediaPointer > 0 Then
If Main.MediaQueue(0).Vox.trim <> "" Then 'there is a vox file to play
MediaPlayer1_Complete 'cause it to play
Else
If Main.MediaQueue(0).Alternate.Trim <> "" Then 'there is alternate text to speak
If TTSReady Then
TTS1.Speak(Main.MediaQueue(0).Alternate, True) 'so speak it
End If
End If
End If
Else 'they've cleared the queue and want it to stop talking
TTS1.Stop
MediaPlayer1.Stop
End If
End Sub
Sub Service_Destroy
MediaPlayer1.Stop
MediaPlayer1.Release
TTS1.Release
End Sub
Sub TTS_Settings
TTS1.SpeechRate = 1
TTS1.Pitch = 1
TTS1.SetLanguage("en","US")
End Sub
Sub TTS1_Ready (Success As Boolean)
If Success Then TTSReady=True
End Sub
'When the media is finished see if there is more to play
Sub MediaPlayer1_Complete
If Main.MediaQueue(0).vox <> "" Then
MediaPlayer1.Load(Main.MediaQueue(0).VoxFldr, Main.MediaQueue(0).Vox)
MediaPlayer1.Play
RemoveFromMediaQueue(0) 'remove it from the queue
End If
End Sub