Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
media.forEach(m => {
const previousToken = m.previousTrack ? m.previousTrack.contentURL : null;
debug('previous token', previousToken);
if (mediaResponseOnly) {
// https://developer.amazon.com/docs/custom-skills/audioplayer-interface-reference.html#playbacknearlyfinished
debug('card is not allowed');
} else {
debug('render card', m.name, m.description);
if (m.imageURL) {
handlerInput.responseBuilder.withStandardCard(m.name, m.description, m.imageURL);
} else {
handlerInput.responseBuilder.withSimpleCard(m.name, m.description);
}
}
const art = new Alexa.ImageHelper()
.withDescription(m.name)
.addImageInstance(m.imageURL)
.getImage();
// TODO: we could find better image for background
const backgroundImage = art;
debug('playback audio', m.contentURL);
handlerInput.responseBuilder.addAudioPlayerPlayDirective(
// behavior,
previousToken ? 'ENQUEUE' : 'REPLACE_ALL',
m.contentURL,
// token (This token cannot exceed 1024 characters)
m.contentURL,
// offsetInMilliseconds
m.offset,
}
responseBuilder.withStandardCard(
getCardTitle(selectedState),
getTextDescription(selectedState),
getSmallImage(selectedState.Abbreviation),
getLargeImage(selectedState.Abbreviation),
);
speechOutput = getSpeechDescription(selectedState);
if (supportsDisplay(handlerInput)) {
const image = new Alexa.ImageHelper()
.addImageInstance(getLargeImage(selectedState.Abbreviation))
.getImage();
const bgImage = new Alexa.ImageHelper()
.addImageInstance(getBackgroundImage(800, 1200, selectedState.Abbreviation))
.getImage();
const title = getCardTitle(selectedState);
const bodyTemplate = bodyTemplateChoice(getCardTitle(selectedState));
const primaryText = new Alexa.RichTextContentHelper()
.withPrimaryText(getTextDescription(selectedState, '<br>'))
.getTextContent();
responseBuilder.addRenderTemplateDirective({
type: bodyTemplate,
backButton: 'visible',
backgroundImage: bgImage,
image,
title,
textContent: primaryText,
});
speechOutput = `This is the ${getBodyTemplateName(bodyTemplate)} template, also known as body template number ${getBodyTemplateNumber(bodyTemplate)}. `;
data.forEach((x) => {
const stateImage = new Alexa.ImageHelper().withDescription(`${x.StateName} state flag`);
for (let y = 0; y < imgHeight.length; y += 1) {
stateImage.addImageInstance(getImageUrl(imgHeight[y], imgWidth[y], x.Abbreviation));
}
statesList.push({
token: x.Abbreviation,
textContent: new Alexa.PlainTextContentHelper()
.withPrimaryText(x.StateName)
.withSecondaryText(`Abbreviation: ${x.Abbreviation}`)
.withTertiaryText(`Capital: ${x.Capital}`)
.getTextContent(),
image: stateImage.getImage(),
});
});
responseBuilder.addRenderTemplateDirective({