I've got a website (www.myexamplewebsite.com) that looks simplified like this:
<html>
<head>
</head>
<body>
<img src="img/speaker-icon.png" onclick="speakerFunction()">
<script>
function speakerFunction() {
var text = new SpeechSynthesisUtterance("This is a test.");
text.lang = 'en-US';
window.speechSynthesis.speak(text);
}
</script>
</body>
</html>
And I have also a simple Android-application which is basically a webview that displays my website:
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
WebView myWebView = (WebView) findViewById(R.id.myWebView);
myWebView.loadUrl("www.myexamplewebsite.com");
myWebView.setWebViewClient(new MyWebViewClient());
WebSettings webSettings = myWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
}
// Use when the user clicks a link from a web page in the WebView
private class MyWebViewClient extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if (Uri.parse(url).getHost().equals("www.myexamplewebsite.com")) {
return false;
}
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
startActivity(intent);
return true;
}
}
}
My problem is the following:
When I visit the example website in a normal browser (Chrome, Firefox) on my desktop-pc it works how it should work. If I click on the image on the website, I can hear the text "This is a test."
If I visit the example website with the Chrome-App for Android on my smartphone it works also. But if I visit the website with the Firefox-App or within my own App with the webview (see above) then it doesn't work.
Update 1: I specified the language explicitely and I tried it with the crosswalk framework but that also didn't solve the problem.