Android Question Play Silence TTS?

Branko Milosevic

Active Member
Licensed User
Can this work to play silence in a TTS stream? playSilence was depreciated in API 21 and replaced with playSilentUtterance so the PlaySilence Sub contains check for API level. Not at the computer with IDE at the moment and haven't sourced an android phones with API 21 to test. Is the TTS library already containing appropriate play silence method?

B4X:
Sub TTS_Ready (Success As Boolean)
        tts.Speak("this is the first sentence", False)
        PlaySilence(3000)
        tts.Speak("this is the second sentence", False)
End Sub

Sub PlaySilence(DurationMs As Long)
       Dim jo AsJavaObject = tts
       Dim p as Phone
          if p.SdkVersion < 21 then
               jo.RunMethod("playSilence", Array(DurationMs, 1, Null))
          else
               jo.RunMethod("playSilentUtterance", Array(DurationMs, 1, Null))
          end if

End Sub
 
Last edited:
Top