Question

I'm using the TTS of google translator in javascript as follows:

<script>
  function playGoogle()
  {
    var audio = new Audio();
    audio.src ="http://translate.google.com/translate_tts?tl=en&q='hello World'";
    audio.play();
  }
</script>

It is working on ios devices (using safari and chrome) but not on Android (using chrome). I used this url in chrome: http://translate.google.com/translate_tts?tl=en&q=hello World On ios devices(chrome and safari) "hello world" is played without clicking on the play button, but on android devices you need to click on the play button in order to hear the 'hello world'.

I think it is the reason why my script doesnt work on Android devices.

Was it helpful?

Solution

Ensure that playGoogle is called via a userGesture such as a click on a button. Chrome for Android will not play Audio or Video without a gesture first.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top