Using this Amazon-provided library, I am working on an alexa skill that plays a queue of short mp3 files. The code that triggers the audio looks like this:
this.response.audioPlayerPlay('REPLACE_ALL', mp3HttpsUrl, mp3HttpsUrl, null, 0);
(function documentation here)
This is further invoked during the PlaybackNearlyFinished
audio event handler to queue up the next audio file URL.
It works fine, but there is about a 3~4 second gap between the audio playback. I would like to reduce the gap, and have as-close-to-uninterrupted playback as possible.
In a browser setting, this would be achieved by pre-loading to cache before the time to play has arrive; when the URL finally does gets called to play, the browser just plays it from local storage, delivering a experience with virtually no lag.
How can this be achieved in an alexa lambda function? How do I pre-load the "on-deck" URL so it eventually plays without a gap?