我正在使用“Alexa Skill Kit”的“AudioPlayer”来传输 HLS 音频格式 URL。我没有从 AWS Lambda 和开发人员门户收到任何错误。我正在使用 Silent Echo ( https://silentecho.bespoken.io/ ) 进行测试。 Alexa 能够播放 MP3 格式的 URL,以及我通过论坛找到的一些 HLS。但是,我的 HLS URL 不起作用。
我的 HLS 网址:http://cpdc101-lh.akamaihd.net/i/ISNCPDCMB1_1@314337/master.m3u8
其他 HLS 网址: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
另一个 HLS URL 正在播放,但我听不到任何声音。尽管如此,他们的工作却让我的 HLS 与 Silent Echo 出现了这个错误“请求的技能响应存在问题”。有人看出我的 HLS 链接和他们的有什么区别吗?
任何人都可以帮我弄清楚如何让此 HLS URL 正常工作吗?
代码:
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;
};
最佳答案
您的直播网址应为 https 。
关于javascript - Alexa 技能 : AudioPlayer HLS stream URL not working,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44766397/