The Alexa skill used to stream audio, but now the stream starts playing and then stops almost immediately after the recent firmware update.
handlerInput.responseBuilder
.speak(`starting ${stream.metadata.title}`)
.addAudioPlayerPlayDirective('REPLACE_ALL', stream.url, stream.token, 0, null, stream.metadata);
return handlerInput.responseBuilder
This code was working correctly until the recent firmware update.
The issue may be caused by the recent firmware update. To fix it, try adding the setShouldEndSession
method to the response builder and set it to false
before returning the response. This will allow the audio stream to continue playing until the user explicitly stops it or the stream ends.
Here’s the updated code:
handlerInput.responseBuilder
.speak(`starting ${stream.metadata.title}`)
.addAudioPlayerPlayDirective('REPLACE_ALL', stream.url, stream.token, 0, null, stream.metadata)
.setShouldEndSession(false);
return handlerInput.responseBuilder;