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.

有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top