My application needs to run a silent mp3 in background. I use TTS synthesizetofile() to convert text to mp3 and TTS playsilence() for playing silence. While I can easily convert normal text to mp3 I cant figure out an easy way to play silence.
For those who would suggest don't play anything for x duration and that will be silence...it will not solve my objective. Because if nothing is being played that would allow other sound application to assume that nothing is being played while here I need a silent pause. Secondly, when nothing is being played, android by default shuts down the application.
Also, the solution is not to create a silent mp3 file manually and put into the application because the pause keeps varying and also dependent on values chosen by the user.
Also, TTS playsilence will not do the job because android does not consider it as background music application and shuts it down in like 5 seconds.
Thanks!
I found a solution myself and sharing for those who would come looking for it here...
Use the same TTS.synthesizetofile() method but instead of text use the text in code below:
<speak version="1.1" ><break time="1500ms" /></speak>
replace 1500ms here with any duration you want either in seconds or milliseconds like "3s" or "3000ms"