我需要在我的alexa技能中执行以下一系列事件,我目前无法确定如何执行此操作。
我对#1有以下意图:
"PlayWarmUp": function(){
console.log("play warm up intent fired");
if (this.event.context.System.device.supportedInterfaces.Display) {
//play warm up video
const builder = new Alexa.templateBuilders.BodyTemplate6Builder();
const template = builder.setTextContent(makeRichText('<font size="7">Are you ready?</font><br/><br/><br/><br/>')).build();
let meta = {
title: "Warmup",
subtitle: null
};
this.response.playVideo(videoURL, meta).renderTemplate(template).hint("'Yes', or 'No', or 'Ready'");
//switch state to workout since we want to handle their responses to the are you ready screen, which is in the WORKOUT state
this.handler.state = states.WORKOUT;
this.emit(":responseReady");
} else {
// Audio only
//
console.log("Audio only for play warm up");
this.response.shouldEndSession(false);
this.response.audioPlayerPlay('ENQUEUE', warmupAudioURL, 'warmup-audio-token', 'previous-token', '0');
this.handler.state = states.WORKOUT;
audioState = states.WARMUP;
this.emit(":responseReady");
}
}
亚马逊为这样的音频事件提供内置意图:
const audioHandlers = {
'PlaybackStarted' : function() {
console.log('Alexa begins playing the audio stream');
this.emit(':responseReady');
},
'PlaybackFinished' : function() {
console.log('The stream comes to an end');
console.log("audioState: ", audioState);
console.log("this ", this);
console.log("context: ", this.context);
if (audioState === states.WARMUP) {
console.log("audio state is warm up...");
// This doesn't work. It does nothing.
//
this.handler.state = states.WORKOUT;
this.emitWithState("WORKOUT");
}
},
'PlaybackStopped' : function() {
console.log('Alexa stops playing the audio stream');
this.emit(':responseReady');
},
'PlaybackNearlyFinished' : function() {
console.log('The currently playing stream is nearly complate and the device is ready to receive a new stream');
this.emit(':responseReady');
},
'PlaybackFailed' : function() {
console.log('Alexa encounters an error when attempting to play a stream');
this.emit(':responseReady');
}
};
上述代码不起作用。我无法打电话给&#34;锻炼&#34;音频结束时的意图。
我还看过使用SSML,但emitWithState()
在讲话结束前发光,只允许90秒的音频。
您无法播放和录制音频,然后向用户询问某些内容,这没有任何意义。这应该是一个基本的对话功能。有人解决了这个问题吗?