alexa-samples / skill-sample-nodejs-audio-player

An Alexa Skill Sample showing how to play long form audio in 3P-skills
Other
470 stars 319 forks source link

PlaybackController.PlayCommandIssued would result in error #157

Closed mfizz1 closed 1 year ago

mfizz1 commented 4 years ago

Unless I am missing something, but wouldn't the following command lead to error since you cannot give a speak directive

if (request.type === 'PlaybackController.PlayCommandIssued') {
      return true;
    }

    if (request.type === 'IntentRequest') {
      return request.intent.name === 'PlayAudio' ||
        request.intent.name === 'AMAZON.ResumeIntent';
    }
  },
  handle(handlerInput) {
    return controller.play(handlerInput);
  },

Which in turn would call:

const controller = {
  async play(handlerInput) {
    const {
      attributesManager,
      responseBuilder
    } = handlerInput;

    const playbackInfo = await getPlaybackInfo(handlerInput);
    const {
      playOrder,
      offsetInMilliseconds,
      index
    } = playbackInfo;

    const playBehavior = 'REPLACE_ALL';
    const podcast = constants.audioData[playOrder[index]];
    const token = playOrder[index];
    playbackInfo.nextStreamEnqueued = false;

    responseBuilder
      .speak(`This is ${podcast.title}`)
      .withShouldEndSession(true)
      .addAudioPlayerPlayDirective(playBehavior, podcast.url, token, offsetInMilliseconds, null);

But at this stage, you would get the following error:

The following directives are not supported: Response may not contain an outputSpeech

aszk commented 1 year ago

Your skill can respond to these requests with AudioPlayer directives to start and stop playback. In addition, "The response cannot include any of the standard properties such as outputSpeech, card, or reprompt". You need to remove .speak() form your response.