我编写了一个 Alexa Skill,它使用 Lambda 函数来播放给定 URL 中的独特音频。
名为“PlayAudio”的 Intent 正在运行,并播放来自 JSON 格式 API 的第一个音频项目。
名为“PlaybackNearlyFinished”的意图不起作用,也就是说,不播放我正在提供的音频文件。有人能确切地破解为什么这不起作用吗?
这是我的 Lambda 函数的一部分,其中包含两个意图:
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 } );
},