forked from irfanhabib/alexacast
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
67 lines (49 loc) · 1.88 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
var _ = require('lodash');
var youtube = require('./youtube');
var twitch = require('./twitch');
var chromecast = require('./chromecast');
var handlers = {
'PlayLiveStream': function () {
if (_.has(this.event.request, 'intent.slots.Movie.value')) {
var movieName = this.event.request.intent.slots.Movie.value;
youtube.searchYouTubeLive(movieName)
.then(function (videoId) {
chromecast.play(videoId);
});
console.log('Playing ' + movieName);
this.emit(':tell', 'Playing on TV', 'Playing YouTube stream for ' + movieName + ' on TV');
} else {
this.emit(':tell', 'I did not quite get that, please provide an addon name');
}
},
'PlayVideo': function () {
if (_.has(this.event.request, 'intent.slots.Movie.value')) {
var movieName = this.event.request.intent.slots.Movie.value;
youtube.searchYouTube(movieName)
.then(function (videoId) {
chromecast.play(videoId);
});
console.log('Playing ' + movieName);
this.emit(':tell', 'Playing on TV', 'Playing YouTube stream for ' + movieName + ' on TV');
} else {
this.emit(':tell', 'I did not quite get that, please provide an addon name');
}
},
'AMAZON.StopIntent': function () {
chromecast.stop();
this.emit(':tell', 'I stopped playing');
},
'AMAZON.PauseIntent': function () {
chromecast.pause();
this.emit(':tell', 'I stopped playing');
},
'AMAZON.ResumeIntent': function () {
chromecast.resume();
this.emit(':tell', 'I stopped playing');
},
'AMAZON.StartOverIntent': function () {
chromecast.seek(0);
this.emit(':tell', 'I stopped playing');
}
};
module.exports.handlers = handlers;