Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

178
Views
Coding Issue Alexa SDK

I am trying to finish up my Alexa App for music, but for some reason, the stop and cancel part of my app isn't working. This is my code (part of it):

(the async stop is what is called when controller.stop is called)

const CancelAndStopIntentHandler = {
   canHandle(handlerInput) {
       return (
           Alexa.getRequestType(handlerInput.requestEnvelope) === "IntentRequest" &&
           (Alexa.getIntentName(handlerInput.requestEnvelope) ===
               "AMAZON.CancelIntent" ||
               Alexa.getIntentName(handlerInput.requestEnvelope) ===
               "AMAZON.StopIntent" ||
               Alexa.getIntentName(handlerInput.requestEnvelope) ===
               "AMAZON.PauseIntent")
       );
   },
   handle(handlerInput) {
       console.log("CancelAndStopIntentHandler");
       handlerInput.responseBuilder.speak("Okay")
       return controller.stop(handlerInput, "okay"); //Goodbye!");
   },
};

-------------------------------------------------------------------------
   async stop(handlerInput, message) {
       var device_id = handlerInput.requestEnvelope.context.System.device.deviceId;
       var info = await getstuffindb(device_id);
       console.log(info.length);
       var deviceMap = JSON.parse(info.devicemap);
       deviceMap[device_id]["is_playing"]=false;
       if (deviceMap[device_id]) {
         deviceMap[device_id]["g_offset"] = handlerInput.requestEnvelope.context.AudioPlayer.offsetInMilliseconds;
         console.log('Stopped at offset', deviceMap[device_id]["g_offset"]);
       }
       await insertintodb(device_id, JSON.stringify(deviceMap), device_id);
       return handlerInput.responseBuilder
           .speak(message)
           .withShouldEndSession(true)
           .addAudioPlayerStopDirective()
           .getResponse();
   },

Error image: enter image description here

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!