AceCentre / pasco

Phrase Auditory Scanning COmmunicator - AAC App for iOS and the Web
https://app.pasco.chat
GNU General Public License v3.0
14 stars 6 forks source link

responsivevoice related playback bug #98

Closed hosseinzoda closed 6 years ago

hosseinzoda commented 6 years ago

I have noticed firefox is not performing responsivevoice's playback sometimes. So i decided to review responsivevoice.js code. And the conclusion was firefox doesn't like audio.src="" when it is already set.

NS_ERROR_DOM_INVALID_STATE_ERR (0x8053000B)
    An attempt was made to use an object which is no longer usable.

And temporary workaround was this. I will contact responsivevoice and notify them about this issue. Until then we can use this function.

        function responsiveVoiceFix (rv) {
          var orgiFallback_audioPool_getAudio = rv.fallback_audioPool_getAudio;
          rv.fallback_audioPool_getAudio = function () {
            if (rv.fallback_audiopool_index >= rv.fallback_audiopool.length) {
              rv.fallback_audiopool = [];
            }
            return orgiFallback_audioPool_getAudio.apply(this, arguments);
          }
          var origClearFallbackPool = rv.clearFallbackPool;
          rv.clearFallbackPool = function () {
            _.each(rv.fallback_audiopool, function (audio) {
              audio.pause();
            });
            rv.fallback_audiopool = [];
            return origClearFallbackPool.apply(this, arguments);
          }
        }

ResponsiveVoice version "1.5.8"