diff --git a/src/constants.js b/src/constants.js index b01aa2e04..43de0c925 100644 --- a/src/constants.js +++ b/src/constants.js @@ -32,6 +32,16 @@ export const ADSENSE_CLIENT = 'ca-pub-7162313874228987'; export const ADD_SLOT_SETTINGS_TOP = '5250438005'; -export const IS_BROWSING_FROM_APPLE = /iPad|iPhone|iPod|Mac/.test( - navigator.userAgent -); +const userAgent = navigator.userAgent; + +export const IS_BROWSING_FROM_APPLE = /iPad|iPhone|iPod|Mac/.test(userAgent); + +export const IS_BROWSING_FROM_APPLE_TOUCH = + IS_BROWSING_FROM_APPLE && 'ontouchend' in document; + +export const IS_BROWSING_FROM_SAFARI = + userAgent.indexOf('Safari') > -1 && + userAgent.indexOf('Chrome') === -1 && + !navigator.userAgent.match(/crios/i) && + !navigator.userAgent.match(/fxios/i) && + !navigator.userAgent.match(/Opera|OPT\//); diff --git a/src/providers/SpeechProvider/tts.js b/src/providers/SpeechProvider/tts.js index f847c2f22..3568e48ad 100644 --- a/src/providers/SpeechProvider/tts.js +++ b/src/providers/SpeechProvider/tts.js @@ -4,7 +4,9 @@ import API from '../../api'; import { AZURE_SPEECH_SERVICE_REGION, AZURE_SPEECH_SUBSCR_KEY, - IS_BROWSING_FROM_APPLE + IS_BROWSING_FROM_APPLE, + IS_BROWSING_FROM_APPLE_TOUCH, + IS_BROWSING_FROM_SAFARI } from '../../constants'; import { getStore } from '../../store'; @@ -267,7 +269,8 @@ const tts = { msg.rate = rate; msg.volume = volume; msg.onend = onend; - synth.cancel(); + if (IS_BROWSING_FROM_SAFARI || IS_BROWSING_FROM_APPLE_TOUCH) + synth.cancel(); synth.speak(msg); } }