Alexa Skills: URL-адрес потока HLS AudioPlayer не работает

1

Я использую "AudioPlayer" в "Alexa Skill Kit" для потоковой передачи URL-адреса формата HLS. Я не получаю ошибок от AWS Lambda и портала разработчиков. Я тестирую, используя Silent Echo (https://silentecho.bespoken.io/). Alexa может воспроизводить MP3-форматированные URL-адреса, а некоторые HLS я нашел в форуме. Однако мой URL HLS не работает.

Мой URL-адрес HLS: http://cpdc101-lh.akamaihd.net/i/ISNCPDCMB1_1@314337/master.m3u8

Другой URL 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

Другой URL HLS играет, но я ничего не слышу. Тем не менее, их работа, в то время как моя HLS с Silent Echo вызывает эту ошибку, "возникла проблема с запрошенными ответами на навыки". Кто-нибудь видит разницу между моей связью HLS и их?

Может ли кто-нибудь помочь мне разобраться, как заставить этот URL-адрес HLS работать?

Код:

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;
};
Теги:
aws-lambda
alexa
alexa-skills-kit

2 ответа

1

ваш URL-адрес канала должен быть https.

0

Спасибо Wejd DAGHFOUS. Я изменил URL-адрес на HTTPS, и ошибка исчезла! Я могу играть сейчас, но, как и другие ссылки HLS, я ничего не слышу.

Спасибо, Хоселюзм. Вы знаете, должен ли HLS быть только аудио, чтобы играть?

Ещё вопросы

Сообщество Overcoder
Наверх
Меню