gpt4 book ai didi

alexa-skills-kit - alexa - audioPlayer.Play 问题在 Echo Show Now Playing 屏幕上显示内容

转载 作者:行者123 更新时间:2023-12-04 11:18:44 25 4
gpt4 key购买 nike

我在理解如何在 audioPlayer“正在播放”屏幕内的 Echo Show 上显示图像时遇到问题。

我目前正在播放音频文件,并希望在“正在播放”屏幕上显示图像。我能得到的最接近的是以下代码,它在音频开始之前显示图像和标题,但随后立即消失,Echo Show 进入“正在播放”屏幕,没有背景图像和元数据。我觉得我已经接近了,但只是不明白如何更新“正在播放”屏幕,而不是紧接在它之前的屏幕。

这是代码的一部分(按上述方式工作):

var handlers = {
'LaunchRequest': function() {
this.emit('PlayStream');
},

'PlayStream': function() {
let builder = new Alexa.templateBuilders.BodyTemplate1Builder();
let template = builder.setTitle('Test Title')
.setBackgroundImage(makeImage('https://link_to_my_image.png'))
.setTextContent(makePlainText('Test Text'))
.build();

this.response.speak('OK.').

audioPlayerPlay(
'REPLACE_ALL',
stream.url,
stream.url,
null,
0)
.renderTemplate(template);

this.emit(':responseReady');
}

我一直在看这个页面 https://developer.amazon.com/docs/custom-skills/audioplayer-interface-reference.html但无法理解如何将该页面上的内容结构转换为我的代码。我假设,从页面上的代码:
{
"type": "AudioPlayer.Play",
"playBehavior": "valid playBehavior value such as ENQUEUE",
"audioItem": {
"stream": {
"url": "https://url-of-the-stream-to-play",
"token": "opaque token representing this stream",
"expectedPreviousToken": "opaque token representing the previous stream",
"offsetInMilliseconds": 0
},
"metadata": {
"title": "title of the track to display",
"subtitle": "subtitle of the track to display",
"art": {
"sources": [
{
"url": "https://url-of-the-album-art-image.png"
}
]
},
"backgroundImage": {
"sources": [
{
"url": "https://url-of-the-background-image.png"
}
]
}
}
}
}

我不知何故需要得到这部分:
"metadata": {
"title": "title of the track to display",
"subtitle": "subtitle of the track to display",
"art": {
"sources": [
{
"url": "https://url-of-the-album-art-image.png"
}
]
},

进入我的代码块:
audioPlayerPlay(
'REPLACE_ALL',
streamInfo.url,
streamInfo.url,
null,
0)
.renderTemplate(template);

(并且可能会丢失 .renderTemplate(template); 部分,因为它只会在“正在播放”屏幕加载之前短暂闪烁。

关于如何实现这一目标的任何想法?

谢谢!

更新:

我在 index.js 中添加了以下内容:
var metadata = { 
title: "title of the track to display",
subtitle: "subtitle of the track to display",
art: {
sources: {
url: "https://url-of-the-album-art-image.png"
}
}
};

并修改了audioPlayer如下:
audioPlayerPlay(
'REPLACE_ALL',
stream.url,
stream.url,
null,
0,
metadata)
.renderTemplate(template);

并按指示修改了 responseBuilder.js:
audioPlayerPlay(behavior, url, token, expectedPreviousToken, offsetInMilliseconds, metadata) {
const audioPlayerDirective = {
type : DIRECTIVE_TYPES.AUDIOPLAYER.PLAY,
playBehavior: behavior,
audioItem: {
stream: {
url: url,
token: token,
expectedPreviousToken: expectedPreviousToken,
offsetInMilliseconds: offsetInMilliseconds,
metadata : metadata
}
}
};

this._addDirective(audioPlayerDirective);
return this;
}

但我仍然没有在“正在播放”屏幕上显示任何内容。

最佳答案

由于某种原因,Echo Show 没有实时更新,需要重新启动才能显示元数据变量中传递的任何内容,这就是我没有看到任何结果的原因。

简单地传递一个变量就可以了。我只需要找出为什么内容会卡在“正在播放”屏幕上并需要重新启动才能工作。

var "metadata": {
"title": "title of the track to display",
"subtitle": "subtitle of the track to display",
"art": {
"sources": [
{
"url": "https://url-of-the-album-art-image.png"
}
]
},

关于alexa-skills-kit - alexa - audioPlayer.Play 问题在 Echo Show Now Playing 屏幕上显示内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50622919/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com