-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathaudioEventHandlers.js
50 lines (48 loc) · 1.71 KB
/
audioEventHandlers.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
var audioEventHandlers = {
PlaybackStarted: function() {
/*
* AudioPlayer.PlaybackStarted Directive received.
* Confirming that requested audio file began playing.
* Do not send any specific response.
*/
console.log('Playback started');
this.emit(':responseReady');
},
PlaybackFinished: function() {
/*
* AudioPlayer.PlaybackFinished Directive received.
* Confirming that audio file completed playing.
* Do not send any specific response.
*/
console.log('Playback finished');
this.emit(':responseReady');
},
PlaybackStopped: function() {
/*
* AudioPlayer.PlaybackStopped Directive received.
* Confirming that audio file stopped playing.
*/
console.log('Playback stopped');
//do not return a response, as per https://developer.amazon.com/docs/custom-skills/audioplayer-interface-reference.html#playbackstopped
this.emit(':responseReady');
},
PlaybackNearlyFinished: function() {
/*
* AudioPlayer.PlaybackNearlyFinished Directive received.
* Replacing queue with the URL again.
* This should not happen on live streams
*/
console.log('Playback nearly finished');
this.emit(':responseReady');
},
PlaybackFailed: function() {
/*
* AudioPlayer.PlaybackFailed Directive received.
* Logging the error and restarting playing.
*/
console.log('Playback Failed : %j', this.event.request.error);
this.response.audioPlayerClearQueue('CLEAR_ENQUEUED');
this.emit(':responseReady');
}
};
module.exports = audioEventHandlers;