问题
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 } );
},
回答1:
It seems that you are including outputSpeech in your response.
This is okay for regular intents, but not for AudioPlayer requests, per this page: https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/custom-audioplayer-interface-reference
And this note specifically:
Seeing the exact payload can help as well. You can use to test it locally and get those: https://bespoken.tools/blog/2016/08/24/introducing-bst-proxy-for-alexa-skill-development
You should be seeing an additional request from Alexa, SystemExceptionEncountered, that should provide more information about what was wrong. It will send this when there is improper response to an AudioPlayer request.
来源:https://stackoverflow.com/questions/41641008/audioplayer-playbacknearlyfinished-request-of-alexa-skills-kit-not-working