Skip to content

Commit af497cc

Browse files
Files modified with new directive
1 parent 40635a0 commit af497cc

File tree

10 files changed

+96
-129
lines changed

10 files changed

+96
-129
lines changed

lambda/custom/README.md

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Getting Started
2+
3+
Visit https://dabblelab.com/templates for a video tutorial about using this skill template.
4+

lambda/custom/index.js

+50-34
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,62 @@
22
/* eslint-disable no-console */
33

44
const Alexa = require('ask-sdk-core');
5-
const videoDocument = require('./video.json');
65

7-
const VIDEO_TOKEN = 'VideoToken';
6+
// Fill in your requirements here:
7+
8+
const VIDEO_URL = 'https://player.vimeo.com/external/582036894.hd.mp4?s=dd1921cfee36c59f0c9179b6e820b8e03afcbee8&profile_id=174',
9+
VIDEO_TITLE = "Sample Video",
10+
VIDEO_SUBTITLE = "Streaming a Video in an Alexa Skill",
11+
TITLE = 'Template Five',
12+
TEXT = `In this tutorial, you'll learn how to create an Alexa skill that streams a video.`;
13+
14+
const LaunchRequestHandler = {
15+
canHandle(handlerInput) {
16+
return Alexa.getRequestType(handlerInput.requestEnvelope) === 'LaunchRequest';
17+
},
18+
handle(handlerInput) {
19+
const speakOutput = 'Welcome to Video App Example. You can say, Play Video, to watch a sample Video! Thanks.';
20+
21+
return handlerInput.responseBuilder
22+
.speak(speakOutput)
23+
.reprompt(speakOutput)
24+
.getResponse();
25+
}
26+
};
827

928
const PlayVideoIntentHandler = {
1029
canHandle(handlerInput) {
11-
return handlerInput.requestEnvelope.request.type === 'LaunchRequest'
12-
|| (handlerInput.requestEnvelope.request.type === 'IntentRequest'
13-
&& handlerInput.requestEnvelope.request.intent.name === 'PlayVideoIntent');
30+
return (handlerInput.requestEnvelope.request.type === 'IntentRequest'
31+
&& handlerInput.requestEnvelope.request.intent.name === 'PlayVideoIntent');
1432
},
1533
handle(handlerInput) {
16-
let responseBuilder = handlerInput.responseBuilder;
17-
let speakOutput = "";
18-
if (Alexa.getSupportedInterfaces(handlerInput.requestEnvelope)['Alexa.Presentation.APL']){
19-
20-
// Add the RenderDocument directive to the responseBuilder
21-
responseBuilder.addDirective({
22-
type: 'Alexa.Presentation.APL.RenderDocument',
23-
token: VIDEO_TOKEN,
24-
document: videoDocument,
25-
});
26-
// Tailor the speech for a device with a screen.
27-
speakOutput += "In this tutorial, you'll learn how to create an Alexa skill that streams a video."
28-
} else {
29-
speakOutput += "Sorry, but your device doesn't support APL.."
30-
}
31-
return responseBuilder
32-
.speak(speakOutput)
33-
//.reprompt('add a reprompt if you want to keep the session open for the user to respond')
34-
.getResponse();
34+
//if (this.event.context.System.device.SupportedInterfaces.VideoApp) {
35+
let responseBuilder = handlerInput.responseBuilder;
36+
if (Alexa.getSupportedInterfaces(handlerInput.requestEnvelope)['VideoApp']) {
37+
38+
handlerInput.responseBuilder
39+
.addDirective({
40+
"type": "VideoApp.Launch",
41+
"version": "1.0",
42+
"videoItem": {
43+
"source": VIDEO_URL,
44+
"metadata": {
45+
"title": TITLE,
46+
"subtitle": VIDEO_SUBTITLE
47+
}
48+
}
49+
50+
})
51+
.speak(TEXT)
52+
} else {
53+
handlerInput.responseBuilder
54+
.speak("The video cannot be played on your device. To watch this video, try launching this skill from an echo show device.");
3555
}
56+
return handlerInput.responseBuilder
57+
58+
.getResponse();
59+
60+
},
3661
};
3762

3863
const HelpIntentHandler = {
@@ -105,20 +130,11 @@ const ErrorHandler = {
105130
},
106131
};
107132

108-
function supportsDisplay(handlerInput) {
109-
const hasDisplay =
110-
handlerInput.requestEnvelope.context &&
111-
handlerInput.requestEnvelope.context.System &&
112-
handlerInput.requestEnvelope.context.System.device &&
113-
handlerInput.requestEnvelope.context.System.device.supportedInterfaces &&
114-
handlerInput.requestEnvelope.context.System.device.supportedInterfaces.Display;
115-
return hasDisplay;
116-
}
117-
118133
const skillBuilder = Alexa.SkillBuilders.custom();
119134

120135
exports.handler = skillBuilder
121136
.addRequestHandlers(
137+
LaunchRequestHandler,
122138
PlayVideoIntentHandler,
123139
AboutIntentHandler,
124140
HelpIntentHandler,

lambda/custom/video.json

-51
This file was deleted.

models/en-AU.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"interactionModel": {
33
"languageModel": {
4-
"invocationName": "video demo",
4+
"invocationName": "video app",
55
"intents": [
66
{
77
"name": "AMAZON.CancelIntent",
@@ -43,5 +43,5 @@
4343
"types": []
4444
}
4545
},
46-
"version": "4"
46+
"version": "2"
4747
}

models/en-CA.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"interactionModel": {
33
"languageModel": {
4-
"invocationName": "video demo",
4+
"invocationName": "video app",
55
"intents": [
66
{
77
"name": "AMAZON.CancelIntent",
@@ -43,5 +43,5 @@
4343
"types": []
4444
}
4545
},
46-
"version": "4"
46+
"version": "1"
4747
}

models/en-GB.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"interactionModel": {
33
"languageModel": {
4-
"invocationName": "video demo",
4+
"invocationName": "video app",
55
"intents": [
66
{
77
"name": "AMAZON.CancelIntent",
@@ -43,5 +43,5 @@
4343
"types": []
4444
}
4545
},
46-
"version": "3"
46+
"version": "1"
4747
}

models/en-IN.json

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"interactionModel": {
33
"languageModel": {
4-
"invocationName": "video demo",
4+
"invocationName": "video app",
55
"intents": [
66
{
77
"name": "AMAZON.CancelIntent",
@@ -25,9 +25,7 @@
2525
"samples": [
2626
"play video",
2727
"watch video",
28-
"start video",
29-
"take me away",
30-
"reenergize me"
28+
"start video"
3129
]
3230
},
3331
{
@@ -43,5 +41,5 @@
4341
"types": []
4442
}
4543
},
46-
"version": "3"
44+
"version": "2"
4745
}

models/en-US.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"interactionModel": {
33
"languageModel": {
4-
"invocationName": "video demo",
4+
"invocationName": "video app",
55
"intents": [
66
{
77
"name": "AMAZON.CancelIntent",
@@ -43,5 +43,5 @@
4343
"types": []
4444
}
4545
},
46-
"version": "2"
46+
"version": "1"
4747
}

readme.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# VideoApp Starter - Alexa Skill Template
44

5-
This is an Alexa skill template that provides a starting point for creating a skill that uses the [APL Interface](https://developer.amazon.com/en-US/docs/alexa/alexa-presentation-language/apl-video.html) to stream native video files to an Amazon Echo Show or Echo Spot.
5+
This is an Alexa skill template that provides a starting point for creating a skill that uses the [VideoApp Interface](https://developer.amazon.com/en-GB/docs/alexa/custom-skills/videoapp-interface-reference.html) to stream native video files to an Amazon Echo Show or Echo Spot.
66

77
### Using this skill template
88

@@ -16,6 +16,6 @@ This is an Alexa skill template that provides a starting point for creating a sk
1616

1717
4. Test the skill with an Alexa device that can play video.
1818

19-
> **NOTE:** You can't test the skill in devices like: Echo Show, Fire TV, some Fire tablets, and other devices.
19+
> **NOTE:** You can test the skill in devices like: Echo Show, Fire TV Cube, some Fire tablets, and other devices.
2020
2121
5. Modify the skill code to use your own stream URL.

skill.json

+29-29
Original file line numberDiff line numberDiff line change
@@ -3,62 +3,62 @@
33
"publishingInformation": {
44
"locales": {
55
"en-US": {
6-
"summary": "A soothing 1-minute video to clear your mind and reenergize your soul.",
6+
"summary": "An entertaining little video to make you feel Happy!",
77
"examplePhrases": [
88
"Alexa open template five",
9-
"Alexa ask template five to take me away",
10-
"Alexa tell template five to reenergize me"
9+
"Alexa ask template five to play video",
10+
"Alexa tell template five to watch video"
1111
],
12-
"name": "video demo",
13-
"description": "A soothing 1-minute video to clear your mind and reenergize your soul.",
12+
"name": "video app",
13+
"description": "An entertaining little video to make you feel Happy!",
1414
"smallIconUri": "file://assets/images/en-US_smallIconUri.png",
1515
"largeIconUri": "file://assets/images/en-US_largeIconUri.png"
1616
},
1717
"en-CA": {
18-
"summary": "A soothing 1-minute video to clear your mind and reenergize your soul.",
18+
"summary": "An entertaining little video to make you feel Happy!",
1919
"examplePhrases": [
2020
"Alexa open template five",
21-
"Alexa ask template five to take me away",
22-
"Alexa tell template five to reenergize me"
21+
"Alexa ask template five to play video",
22+
"Alexa tell template five to watch video"
2323
],
24-
"name": "video demo",
25-
"description": "A soothing 1-minute video to clear your mind and reenergize your soul.",
24+
"name": "video app",
25+
"description": "An entertaining little video to make you feel Happy!",
2626
"smallIconUri": "file://assets/images/en-CA_smallIconUri.png",
2727
"largeIconUri": "file://assets/images/en-CA_largeIconUri.png"
2828
},
2929
"en-IN": {
30-
"summary": "A soothing 1-minute video to clear your mind and reenergize your soul.",
30+
"summary": "An entertaining little video to make you feel Happy!",
3131
"examplePhrases": [
3232
"Alexa open template five",
33-
"Alexa ask template five to take me away",
34-
"Alexa tell template five to reenergize me"
33+
"Alexa ask template five to play video",
34+
"Alexa tell template five to watch video"
3535
],
36-
"name": "video demo",
37-
"description": "A soothing 1-minute video to clear your mind and reenergize your soul.",
36+
"name": "video app",
37+
"description": "An entertaining little video to make you feel Happy!",
3838
"smallIconUri": "file://assets/images/en-IN_smallIconUri.png",
3939
"largeIconUri": "file://assets/images/en-IN_largeIconUri.png"
4040
},
4141
"en-AU": {
42-
"summary": "A soothing 1-minute video to clear your mind and reenergize your soul.",
42+
"summary": "An entertaining little video to make you feel Happy!",
4343
"examplePhrases": [
4444
"Alexa open template five",
45-
"Alexa ask template five to take me away",
46-
"Alexa tell template five to reenergize me"
45+
"Alexa ask template five to play video",
46+
"Alexa tell template five to watch video"
4747
],
48-
"name": "video demo",
49-
"description": "A soothing 1-minute video to clear your mind and reenergize your soul.",
48+
"name": "video app",
49+
"description": "An entertaining little video to make you feel Happy!",
5050
"smallIconUri": "file://assets/images/en-AU_smallIconUri.png",
5151
"largeIconUri": "file://assets/images/en-AU_largeIconUri.png"
5252
},
5353
"en-GB": {
54-
"summary": "A soothing 1-minute video to clear your mind and reenergize your soul.",
54+
"summary": "An entertaining little video to make you feel Happy!",
5555
"examplePhrases": [
5656
"Alexa open template five",
57-
"Alexa ask template five to take me away",
58-
"Alexa tell template five to reenergize me"
57+
"Alexa ask template five to play video",
58+
"Alexa tell template five to watch video"
5959
],
60-
"name": "video demo",
61-
"description": "A soothing 1-minute video to clear your mind and reenergize your soul.",
60+
"name": "video app",
61+
"description": "An entertaining little video to make you feel Happy!",
6262
"smallIconUri": "file://assets/images/en-GB_smallIconUri.png",
6363
"largeIconUri": "file://assets/images/en-GB_largeIconUri.png"
6464
}
@@ -78,7 +78,7 @@
7878
"apis": {
7979
"custom": {
8080
"endpoint": {
81-
"uri": "arn:aws:lambda:us-east-1:325775800922:function:ef704cfb-0ebd-4ef3-9411-97d118428612:Release_0"
81+
"uri": "arn:aws:lambda:us-east-1:325775800922:function:c64f3039-f1a0-4d3b-ab14-4b668f7ba2bf:Release_0"
8282
},
8383
"interfaces": [
8484
{
@@ -157,17 +157,17 @@
157157
"regions": {
158158
"EU": {
159159
"endpoint": {
160-
"uri": "arn:aws:lambda:eu-west-1:325775800922:function:ef704cfb-0ebd-4ef3-9411-97d118428612:Release_0"
160+
"uri": "arn:aws:lambda:eu-west-1:325775800922:function:c64f3039-f1a0-4d3b-ab14-4b668f7ba2bf:Release_0"
161161
}
162162
},
163163
"NA": {
164164
"endpoint": {
165-
"uri": "arn:aws:lambda:us-east-1:325775800922:function:ef704cfb-0ebd-4ef3-9411-97d118428612:Release_0"
165+
"uri": "arn:aws:lambda:us-east-1:325775800922:function:c64f3039-f1a0-4d3b-ab14-4b668f7ba2bf:Release_0"
166166
}
167167
},
168168
"FE": {
169169
"endpoint": {
170-
"uri": "arn:aws:lambda:us-west-2:325775800922:function:ef704cfb-0ebd-4ef3-9411-97d118428612:Release_0"
170+
"uri": "arn:aws:lambda:us-west-2:325775800922:function:c64f3039-f1a0-4d3b-ab14-4b668f7ba2bf:Release_0"
171171
}
172172
}
173173
}

0 commit comments

Comments
 (0)