I am using the "AudioPlayer" of the "Alexa Skill Kit" to stream an HLS audio format URL. I am receiving no errors from the AWS Lambda and from the Developer Portal. I am testing by using the Silent Echo (https://silentecho.bespoken.io/). Alexa is able to play MP3 formatted URLs, and some HLS I found through the forum. However, my HLS URL is not working.
My HLS URL: http://cpdc101-lh.akamaihd.net/i/ISNCPDCMB1_1@314337/master.m3u8
Other HLS URL: https://as-hls-ww-live.bbcfmt.hs.llnwd.net/pool_6/live/bbc_radio_fourfm/bbc_radio_fourfm.isml/bbc_radio_fourfm-audio%3d96000.norewind.m3u8
The other HLS URL is playing, but I don't hear anything. Nonetheless, their's work while my HLS with Silent Echo comes up with this error "there was a problem with the requested skills response." Does anyone see the difference between my HLS link and their's?
Can anyone help me figure out how to get this HLS URL to work?
The code:
var lastPlayedByUser = {};
var streamURL = "http://cpdc101-lh.akamaihd.net/i/ISNCPDCMB1_1@314337/master.m3u8";
exports.handler = function(event, context) {
var player = new SidRothPlayer(event, context);
player.handle();
};
var SidRothPlayer = function (event, context) {
this.event = event;
this.context = context;
};
SidRothPlayer.prototype.handle = function () {
var requestType = this.event.request.type;
var userId = this.event.context ? this.event.context.System.user.userId : this.event.session.user.userId;
if (requestType === "LaunchRequest") {
this.play(streamURL, 0);
} else if (requestType === "IntentRequest") {
var intent = this.event.request.intent;
if (intent.name === "Play") {
this.play(streamURL, 0);
} else if (intent.name === "AMAZON.PauseIntent") {
this.stop();
} else if (intent.name === "AMAZON.ResumeIntent") {
var lastPlayed = this.loadLastPlayed(userId);
var offsetInMilliseconds = 0;
if (lastPlayed !== null) {
offsetInMilliseconds = lastPlayed.request.offsetInMilliseconds;
}
this.play(streamURL, offsetInMilliseconds);
}
} else if (requestType === "AudioPlayer.PlaybackStopped") {
this.saveLastPlayed(userId, this.event);
this.context.succeed(true);
}
};
SidRothPlayer.prototype.play = function (audioURL, offsetInMilliseconds) {
var response = {
version: "1.0",
response: {
shouldEndSession: true,
directives: [
{
type: "AudioPlayer.Play",
playBehavior: "REPLACE_ALL",
audioItem: {
stream: {
url: audioURL,
token: "0",
expectedPreviousToken: null,
offsetInMilliseconds: offsetInMilliseconds
}
}
}
]
}
};
this.context.succeed(response);
};
SidRothPlayer.prototype.stop = function () {
var response = {
version: "1.0",
response: {
shouldEndSession: true,
directives: [
{
type: "AudioPlayer.Stop"
}
]
}
};
this.context.succeed(response);
};
SidRothPlayer.prototype.saveLastPlayed = function (userId, lastPlayed) {
lastPlayedByUser[userId] = lastPlayed;
};
SidRothPlayer.prototype.loadLastPlayed = function (userId) {
var lastPlayed = null;
if (userId in lastPlayedByUser) {
lastPlayed = lastPlayedByUser[userId];
}
return lastPlayed;
};