I've written an Alexa Skill that uses a Lambda Function to play unique audio from a given URL.
The Intent called "PlayAudio" is working and plays the first audio item from our JSON-formatted API.
The Intent called "PlaybackNearlyFinished" does not work, aka, does not play the audio file I am feeding it. Can anybody crack exactly why this doesn't work?
Here is a section from my Lambda Function, which contains the two Intents:
Fact.prototype.intentHandlers = {
"PlayAudio": function (event, context, response) {
fetchEnseParse("/latest", function(body) {
if(body == "error") {
}
else {
var directives = body.enses.map(function(ense) {
var a = ense[1].fileUrl;
return {
'playBehavior': 'REPLACE_ALL',
'audioItem':
{
'stream':
{
'url': 'https://s3.amazonaws.com/media.ense.nyc/enses/2017_01_13T16_57_20.190Z/30312/0',
'token': '33529',
'offsetInMilliseconds': 0
}
},
'type': 'AudioPlayer.Play'
};
})
}
var jsonresponse = {
'outputSpeech': {
'text': '',
'type': 'PlainText'
},
'directives': [directives[0]]
};
response.justUseThisJsonPlease( { response: jsonresponse } );
});
},
"AudioPlayer.PlaybackNearlyFinished" : function(event, context, response) {
var second =
{
"type": "AudioPlayer.Play",
"playBehavior": "REPLACE_ENQUEUED",
"audioItem": {
"stream": {
"url": "https://s3.amazonaws.com/media.ense.nyc/enses/violetindigoviolet/30034/0",
"token": "33530",
"offsetInMilliseconds": 0
}
}
}
response.justUseThisJsonPlease( { response: second } );
},