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

Before saying goodbye and stopping, check first whether this skill is currently playing audio. #158

Open mlopezr opened 4 years ago

mlopezr commented 4 years ago

Issue #, if available:

If users say "Alexa, stop" when AudioPlayer was last used by a custom skill, that skill will receive an AMAZON.StopIntent request, even if audio is not playing any more.

Before giving a goodbye message, a custom skill needs to check whether it is currently playing audio.

Description of changes:

When audio is currently playing, context in the intent request looks like:

  "context": {
    "AudioPlayer": {
      "offsetInMilliseconds": 21264,
      "token": "https://example.com/stream/",
      "playerActivity": "PLAYING"
    },

Here's what context looks like if playback is already stopped:

  "context": {
    "AudioPlayer": {
      "offsetInMilliseconds": 21264,
      "token": "https://example.com/stream/",
      "playerActivity": "STOPPED"
    },

I have added checks for StopIntent and PauseIntent for both single-stream and multiple-stream, with unit tests.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

ghost commented 4 years ago

Hello! I don't understand why this is bad:

"If users say "Alexa, stop" when AudioPlayer was last used by a custom skill, that skill will receive an AMAZON.StopIntent request, even if audio is not playing any more."

I added your code, but now I have problems where I can never stop playing. Is it correct?