Alexa.MediaDetailsNavigator (VSK Fire TV)
当用户请求查看有关特定项目的更多详细信息时(例如,“显示某标题视频的更多详细信息”),Alexa.MediaDetailsNavigator接口会向您的Lambda发送DisplayDetails指令,以提供有关该项目的信息。MediaDetailsNavigator接口以UIController中所述的用户接口状态报告为基础构建。如果您已经在实现UIController,那么同时实现MediaDetailsNavigator来处理这些场景也是有意义的。
MediaDetailsNavigator接口仅支持云端集成。- 详细解释
- 支持的表述
- 发送用户界面状态报告
- 用户界面状态报告示例和架构、有效负载定义、数据结构
- DisplayDetails指令示例
- 有效负载定义
- 用户界面状态报告和UIController指令示例
- 示例应用集成
详细解释
Alexa.MediaDetailsNavigator接口提供有关特定媒体项目的更多信息。例如,客户可能会说出:“Alexa, show more details about Iron Man”(Alexa,显示Iron Man的更多详细信息)或“Alexa, show details about number three”(Alexa,显示有关第三项的详细信息)。 或者在聚焦元素(选中)后,用户可以简单地说出“Alexa, show details”(Alexa,显示详细信息)。 此请求不是导航指令(因此不由UIController处理),也不是媒体播放请求(因此不由SearchAndPlay处理),而是请求提供有关特定“实体”的更多详细信息。
在Alexa的话语中,实体是指存在的项目类型。与Fire TV相关的主要实体包括Video、Episode和Event。在配置对MediaDetailsNavigator的支持时,应指明您的应用支持哪些实体。这种语义详细信息让Alexa能够根据应用屏幕上的内容更好地理解客户的请求。
MediaDetailsNavigator使用UIController中所述的相同用户界面报告。您送入用户界面状态报告,其中描述了屏幕中显示的元素(每次屏幕更改时都会更新)。当客户要求提供有关屏幕上项目的更多详细信息时,Alexa会向您的Lambda发送一条名为DisplayDetails的MediaDetailsNavigator指令,其中包含特定元素名称和来自您的用户界面状态的详细信息。
支持的表述
当用户询问有关特定项目的更多详细信息时,Alexa会向您的Lambda发送DisplayDetails指令(命名空间为MediaDetailsNavigator)。示例表述包括以下内容:
- “Alexa, show details for Breaking Bad”(Alexa,显示Breaking Bad的详细信息)
- “Alexa, show details for comedy movies”(Alexa,显示喜剧电影的详细信息)
- “Alexa, show details for Bosch”(Alexa,显示Bosch的详细信息)
- “Alexa, show details for number 2”(Alexa,显示第2项的详细信息)
- “Alexa, show details”(Alexa,显示详细信息)[在聚焦了实体时]
- “Alexa, show details for this”(Alexa,显示此项的详细信息)[在聚焦了实体时]
[在聚焦了实体时] 是指客户在屏幕上选择了一个元素。
下表显示了上述表述在不同区域设置中经过适当翻译的情况。
| 功能 | 表述示例 | 预期响应 | 
|---|---|---|
| 显示/查看有关 [标题] 的详细信息 可选 | Show details on interstellar | 显示有关某标题作品的更多详细信息。 | 
| 功能 | 表述示例 | 预期响应 | 
|---|---|---|
| 显示/查看有关 [标题] 的详细信息 可选 | montre les informations sur [VideoName] *affiche moi plus de détails à propos de [VideoName] voir plus d'infos sur [VideoName] | 显示有关某标题作品的更多详细信息。 | 
| 功能 | 表述示例 | 预期响应 | 
|---|---|---|
| 显示/查看有关 [标题] 的详细信息 可选 | montre les informations sur [VideoName] *affiche moi plus de détails à propos de [VideoName] voir plus d'infos sur [VideoName] | 显示有关某标题作品的更多详细信息。 | 
| 功能 | 表述示例 | 预期响应 | 
|---|---|---|
| 显示/查看有关 [标题] 的详细信息 可选 | zeig mir mehr details über [VideoName] an details zu [VideoName] sehen | 显示有关某标题作品的更多详细信息。 | 
| 功能 | 表述示例 | 预期响应 | 
|---|---|---|
| 显示/查看有关 [标题] 的详细信息 可选 | interstellar की जानकारी दिखाओ | 显示有关某标题作品的更多详细信息。 | 
| 功能 | 表述示例 | 预期响应 | 
|---|---|---|
| 显示/查看有关 [标题] 的详细信息 可选 | *mostra mi ulteriori informazioni/dettagli su aladdin *mostra mi / vedi dettagli su aladdin | 显示有关某标题作品的更多详细信息。 | 
| 功能 | 表述示例 | 预期响应 | 
|---|---|---|
| 显示/查看有关 [标题] 的详细信息 可选 | 坂道のアポロンの詳細を見せて | 显示有关某标题作品的更多详细信息。 | 
| 功能 | 表述示例 | 预期响应 | 
|---|---|---|
| 显示/查看有关 [标题] 的详细信息 可选 | Procurar/procura/procure por todos Mostrar/mostra/mostre detalhes Mostrar/mostra/mostredetalhes do [VideoName] | 显示有关某标题作品的更多详细信息。 | 
| 功能 | 表述示例 | 预期响应 | 
|---|---|---|
| 显示/查看有关 [标题] 的详细信息 可选 | muéstra me información de aladín enséña me información de aladín ver detalles sobre enséña aladín ver detalles de aladín | 显示有关某标题作品的更多详细信息。 | 
发送用户界面状态报告
按照UIController中概述的相同流程发送用户界面状态报告。
支持VSK的应用
您需要在Alexa客户端库中添加对MediaDetailsNavigator的支持。在initializeAlexaClient方法中,将getMediaDetailsNavigatorCapability添加到supportedCapabilities列表中。
    private void initializeAlexaClient() {
        // 检索AlexaClientManager的共享实例
        final AlexaClientManager clientManager = AlexaClientManager.getSharedInstance();
        // 收集您的技能ID
        final String alexaSkillId = "<插入技能ID>";
        // 创建技能中支持的功能的列表。
        final List<AlexaVideoCapability> supportedCapabilities = new ArrayList<>();
        supportedCapabilities.add(getAlexaChannelControllerCapability());
        supportedCapabilities.add(getAlexaPlaybackControllerCapability());
        supportedCapabilities.add(getAlexaRemoteVideoPlayerCapability());
        supportedCapabilities.add(getAlexaSeekControllerCapability());
        supportedCapabilities.add(getAlexaKeypadControllerCapability());
        supportedCapabilities.add(getAlexaUIControllerCapability()); // 添加对用户界面控制器的支持
        supportedCapabilities.add(getMediaDetailsNavigatorCapability()); // 添加对MediaDetailsNavigator的支持
        // 通过调用initialize() 初始化客户端库。
        clientManager.initializeClient(getApplicationContext(),
                alexaSkillId,
                AlexaClientManager.SKILL_STAGE_DEVELOPMENT,
                supportedCapabilities);
    }
支持VSK的设备
请参阅发送用户界面状态报告。但是,在步骤3 - 指明在检测期间会主动报告属性中,指明对MediaDetailsNavigator的支持,如下所示:
{
    "event": {
        "header": {
            "correlationToken": "dFMb0z+PgpgdDmluhJ1LddFvSqZ/jCc8ptlAKulUj90jSqg==",
            "messageId": "93e434b3-74ee-4a87-aad8-317a363ceb6d",
            "name": "Discover.Response",
            "namespace": "Alexa.Discovery",
            "payloadVersion": “3.0”  
        },
        "payload": {
            "endpoints": [
                {
                    "capabilities": [
                        {
                            "interface": "Alexa.MediaDetailsNavigator",
                            "type": "AlexaInterface",
                            "version": "3.0",
                            "configurations": {
                                "entityTypes": [
                                    "Video",
                                    "App"
                                ]
                            }
                        }
                    ],
                    "cookie": {
                        "cookie1": "key1",
                        "cookie2": "key2"
                    },
                    "description": "向客户显示的设备描述",
                    "endpointId": "Unique Device Identifier",
                    "friendlyName": "Upstairs Amazon Player",
                    "manufacturerName": "Amazon"
                }
            ]
        }
    }
}
要指明对MediaDetailsNavigator的支持,可纳入capabilities数组中显示的对象。这包括提供一个包含entityTypes数组的configurations对象。在此数组中,您可以列出您的应用支持的实体类型。尽管Alexa有许多不同的实体类型,但MediaDetailsNavigator接口仅支持两个实体类型: Video和App。
| 实体 | 描述 | 
|---|---|
| Video | Video代表视频内容片段的识别数据。 | 
| App | App代表用户在表述中指定的明确的应用名称。 | 
用户界面状态报告示例和架构、有效负载定义、数据结构
UIController文档中标题为用户界面状态报告示例和架构的部分中描述了您发送的用户界面状态报告。同样,有效负载定义中描述了用户界面状态报告的有效负载定义,数据结构中也描述了用户界面报告的数据结构,所有这些内容都在UIController文档中。MediaDetailsNavigator以您已经在UIController中实现的功能为基础构建。
DisplayDetails指令示例
当客户按照支持的表述中的描述提出请求时,MediaDetailsNavigator接口会向您的Lambda发送名为DisplayDetails的指令。以下是示例指令:
{
    "directive": {
        "endpoint": {
            "cookie": {},
            "endpointId": "<目标终端的标识符>",
            "scope": {
                "token": "<OAuth2持有者令牌>",
                "type": "BearerToken"
            }
        },
        "header": {
            "correlationToken": "dFMb0z+PgpgdDmluhJ1LddFvSqZ/jCc8ptlAKulUj90jSqg==",
            "messageId": "9451490f-9457-4197-93be-200f9e37b776",
            "name": "DisplayDetails",
            "namespace": "Alexa.MediaDetailsNavigator",
            "payloadVersion": “3.0”  
        },
        "payload": {
            "entity":
                {
                    "externalIds": {
                        "mediaBrowseId": "ref1"
                    },
                    "value": "Captain Fantastic",
                    "type": "Video"
                }
         }
    }
}
有效负载定义
DisplayDetails指令的payload取决于返回的实体类型。在前面的示例中,payload包含Video实体。对于Video和App实体类型,将返回以下有效负载:
Video
Video代表视频内容片段的识别数据;例如,“Manchester by the Sea”可能包含以下项:
| Video有效负载字段 | 描述 | 类型 | 示例 | 
|---|---|---|---|
| externalIds | 对象 | — | |
| ASIN | 该实体的外部ASIN | 字符串 | B01M3X9T06 | 
| └─ gracenote | Gracenote标识符 | 字符串 | MV0000000666661 | 
| userConfirmations | 包含有关商品的用户确认信息的对象 | 对象 | |
| └─ entitlementVoiceActivation | 通知合作伙伴观看期限或权利的语音启用是否成功的标记。可能的值 - CONFIRMED(可选)。 | 枚举;默认策略 - 忽略无法识别的值 | CONFIRMED | 
| uri | 映射到视频的URI | URI | entity://provider/movie/manchesterbythesea | 
| value | 视频的名称 | 字符串 | Manchester by the Sea | 
App
App代表用户在口头上指定的明确应用名称;例如,“Manchester by the Sea on Prime”(Prime上的Manchester by the Sea)可能包含以下项:
| App有效负载字段 | 描述 | 类型 | 示例 | 
|---|---|---|---|
| externalIds | 对象 | — | |
| └─ ENTITY_ID | 应用列表中的应用标识符。 | 字符串 | amzn1.alexa-ask-target.app.72095 | 
| value | 应用程序的名称 | 字符串 | Prime Video  | 
用户界面状态报告和UIController指令示例
以下示例显示了示例屏幕、发送的用户界面状态报告、客户的表述以及Alexa向您的Lambda发送的DisplayDetails指令。
命名选择示例
在此示例中,屏幕在屏幕上显示不同的标题。客户想查看有关自己具体命名的特定商品的详细信息。
用户看到的屏幕:

{
  "context": {
    "properties": [
    ]
  },
  "event": {
    "header": {
      "messageId": "abc-123-def-456",
      "namespace": "Alexa",
      "name": "ChangeReport",
      "payloadVersion": "3"
    },
    "endpoint": {
      "scope": {
        "type": "AMAZON.BearerToken",
        "token": "access-token-from-Amazon"
      },
      "endpointId": "endpoint-001"
    },
    "payload": {
      "change": {
        "cause": {
          "type": "AMAZON.PHYSICAL_INTERACTION"
        },
        "properties": [
          {
            "namespace": "Alexa.UIController",
            "name": "uiElements",
            "value": {
              "scene": {
                "sceneId": "scene-id-004"
              },
              "elements": [
                {
                  "entity": {
                    "type": "AMAZON.ItemList",
                    "externalIds": {
                      "entityId": "webpage-001"
                    }
                  },
                  "elementId": "elementId-001",
                  "uiSupportedActions": [
                    "SCROLL_DOWN",
                    "SCROLL_FORWARD"
                  ],
                  "elements": [
                    {
                      "entity": {
                        "type": "AMAZON.VideoObject",
                        "name": {
                          "value": "Iron Man"
                        },
                        "externalIds": {
                          "entityId": "video-001"
                        }
                      },
                      "ordinal": 1,
                      "elementId": "elementId-002",
                      "uiSupportedActions": [
                        "SELECT"
                      ]
                    },
                    {
                      "entity": {
                        "type": "AMAZON.VideoObject",
                        "name": {
                          "value": "Interstellar"
                        },
                        "externalIds": {
                          "entityId": "video-002"
                        }
                      },
                      "ordinal": 2,
                      "elementId": "elementId-003",
                      "uiSupportedActions": [
                        "SELECT"
                      ]
                    },
                    {
                      "entity": {
                        "type": "AMAZON.VideoObject",
                        "name": {
                          "value": "Captain Fantastic"
                        },
                        "externalIds": {
                          "entityId": "video-003"
                        }
                      },
                      "ordinal": 3,
                      "elementId": "elementId-004",
                      "uiSupportedActions": [
                        "SELECT"
                      ]
                    },
                    {
                      "entity": {
                        "type": "AMAZON.VideoObject",
                        "name": {
                          "value": "The Dressmaker"
                        },
                        "externalIds": {
                          "entityId": "video-004"
                        }
                      },
                      "ordinal": 4,
                      "elementId": "elementId-005",
                      "uiSupportedActions": [
                        "SELECT"
                      ]
                    },
                    {
                      "entity": {
                        "type": "AMAZON.VideoObject",
                        "name": {
                          "value": "Gaurdians of the Galaxy"
                        },
                        "externalIds": {
                          "entityId": "video-005"
                        }
                      },
                      "ordinal": 5,
                      "elementId": "elementId-006",
                      "uiSupportedActions": [
                        "SELECT"
                      ]
                    },
                    {
                      "entity": {
                        "type": "AMAZON.VideoObject",
                        "name": {
                          "value": "Passengers"
                        },
                        "externalIds": {
                          "entityId": "video-006"
                        }
                      },
                      "ordinal": 6,
                      "elementId": "elementId-007",
                      "uiSupportedActions": [
                        "SELECT"
                      ]
                    }
                  ]
                }
              ]
            },
            "timeOfSample": "2017-02-03T16:20:50.52Z",
            "uncertaintyInMilliseconds": 0
          }
        ]
      }
    }
  }
}
客户表述: “Alexa, show details on Captain fantastic”(Alexa,显示Captain fantastic的详细信息)
{
    "directive": {
        "endpoint": {
            "cookie": {},
            "endpointId": "<目标终端的标识符>",
            "scope": {
                "token": "<OAuth2持有者令牌>",
                "type": "BearerToken"
            }
        },
        "header": {
            "correlationToken": "dFMb0z+PgpgdDmluhJ1LddFvSqZ/jCc8ptlAKulUj90jSqg==",
            "messageId": "9451490f-9457-4197-93be-200f9e37b776",
            "name": "DisplayDetails",
            "namespace": "Alexa.MediaDetailsNavigator",
            "payloadVersion": “3.0”  
        },
        "payload": {
            "entity":
                {
                    "externalIds": {
                        "mediaBrowseId": "ref1"
                    },
                    "value": "Captain Fantastic",
                    "type": "Video"
                }
         }
    }
}
顺序选择示例
在此示例中,屏幕以不同的序号显示内容(位置,例如数字1、2、3等)。用户希望查看有关特定项目的详细信息,并使用序号来标识该项目,而不是通过命名标题来进行标识。
用户看到的屏幕:

{
  "context": {
    "properties": [
    ]
  },
  "event": {
    "header": {
      "messageId": "abc-123-def-456",
      "namespace": "Alexa",
      "name": "ChangeReport",
      "payloadVersion": "3"
    },
    "endpoint": {
      "scope": {
        "type": "AMAZON.BearerToken",
        "token": "access-token-from-Amazon"
      },
      "endpointId": "endpoint-001"
    },
    "payload": {
      "change": {
        "cause": {
          "type": "AMAZON.PHYSICAL_INTERACTION"
        },
        "properties": [
          {
            "namespace": "Alexa.UIController",
            "name": "uiElements",
            "value": {
              "scene": {
                "sceneId": "scene-id-004"
              },
              "elements": [
                {
                  "entity": {
                    "type": "AMAZON.ItemList",
                    "externalIds": {
                      "entityId": "webpage-001"
                    }
                  },
                  "elementId": "elementId-001",
                  "uiSupportedActions": [
                    "SCROLL_DOWN",
                    "SCROLL_FORWARD"
                  ],
                  "elements": [
                    {
                      "entity": {
                        "type": "AMAZON.VideoObject",
                        "name": {
                          "value": "Iron Man"
                        },
                        "externalIds": {
                          "entityId": "video-001"
                        }
                      },
                      "ordinal": 1,
                      "elementId": "elementId-002",
                      "uiSupportedActions": [
                        "SELECT"
                      ]
                    },
                    {
                      "entity": {
                        "type": "AMAZON.VideoObject",
                        "name": {
                          "value": "Interstellar"
                        },
                        "externalIds": {
                          "entityId": "video-002"
                        }
                      },
                      "ordinal": 2,
                      "elementId": "elementId-003",
                      "uiSupportedActions": [
                        "SELECT"
                      ]
                    },
                    {
                      "entity": {
                        "type": "AMAZON.VideoObject",
                        "name": {
                          "value": "Captain Fantastic"
                        },
                        "externalIds": {
                          "entityId": "video-003"
                        }
                      },
                      "ordinal": 3,
                      "elementId": "elementId-004",
                      "uiSupportedActions": [
                        "SELECT"
                      ]
                    },
                    {
                      "entity": {
                        "type": "AMAZON.VideoObject",
                        "name": {
                          "value": "The Dressmaker"
                        },
                        "externalIds": {
                          "entityId": "video-004"
                        }
                      },
                      "ordinal": 4,
                      "elementId": "elementId-005",
                      "uiSupportedActions": [
                        "SELECT"
                      ]
                    },
                    {
                      "entity": {
                        "type": "AMAZON.VideoObject",
                        "name": {
                          "value": "Gaurdians of the Galaxy"
                        },
                        "externalIds": {
                          "entityId": "video-005"
                        }
                      },
                      "ordinal": 5,
                      "elementId": "elementId-006",
                      "uiSupportedActions": [
                        "SELECT"
                      ]
                    },
                    {
                      "entity": {
                        "type": "AMAZON.VideoObject",
                        "name": {
                          "value": "Passengers"
                        },
                        "externalIds": {
                          "entityId": "video-006"
                        }
                      },
                      "ordinal": 6,
                      "elementId": "elementId-007",
                      "uiSupportedActions": [
                        "SELECT"
                      ]
                    }
                  ]
                }
              ]
            },
            "timeOfSample": "2017-02-03T16:20:50.52Z",
            "uncertaintyInMilliseconds": 0
          }
        ]
      }
    }
  }
}
客户表述: “Alexa, show details on number one”(Alexa,显示第一项的详细信息)
{
    "directive": {
        "endpoint": {
            "cookie": {},
            "endpointId": "<目标终端的标识符>",
            "scope": {
                "token": "<OAuth2持有者令牌>",
                "type": "BearerToken"
            }
        },
        "header": {
            "correlationToken": "dFMb0z+PgpgdDmluhJ1LddFvSqZ/jCc8ptlAKulUj90jSqg==",
            "messageId": "9451490f-9457-4197-93be-200f9e37b776",
            "name": "DisplayDetails",
            "namespace": "Alexa.MediaDetailsNavigator",
            "payloadVersion": “3.0”  
        },
        "payload": {
            "entities":
                {
                    "externalIds": {
                        "mediaBrowseId": "ref1"
                    },
                    "value": "钢铁侠",
                    "type": "Video"
                }
          }
    }
}
“select this”(选择此项)示例
在此示例中,用户选择了一个标题 ("The Marvelous Mrs. Maisel") 以查看详细信息。应用会向用户展示内容详细信息。然后用户说出“select this”(选择此项)。 这种语音模式之所以被称为“指代”,是因为用户将指代物从标题 ("The Marvelous Mrs. Maisel") 更改为较短的缩写 ("this");在这两种情况下,指代对象指的是同一个项目。
用户看到的屏幕:

{
  "context": {
    "properties": [
    ]
  },
  "event": {
    "header": {
      "messageId": "abc-123-def-456",
      "namespace": "Alexa",
      "name": "ChangeReport",
      "payloadVersion": "3"
    },
    "endpoint": {
      "scope": {
        "type": "AMAZON.BearerToken",
        "token": "access-token-from-Amazon"
      },
      "endpointId": "endpoint-001"
    },
    "payload": {
      "change": {
        "cause": {
          "type": "PHYSICAL_INTERACTION"
        },
        "properties": [
          {
            "namespace": "Alexa.UIController",
            "name": "uiElements",
            "value": {
              "scene": {
                "sceneId": "scene-id-001"
              },
              "elements": [
                {
                  "entity": {
                    "type": "AMAZON.VideoObject",
                    "name": {
                      "value": "The Marvelous Mrs. Maisel"
                    },
                    "externalIds": {
                      "entityId": "video-001"
                    }
                  },
                  "elementId": "element-010",
                  "uiSupportedActions": [
                    "SELECT"
                  ],
                  "elements": [
                    {
                      "entity": {
                        "type": "AMAZON.Thing",
                        "name": {
                          "value": "立即使用Prime观看"
                        },
                        "externalIds": {
                          "entityId": "webPageButton-001"
                        }
                      },
                      "elementId": "element-011",
                      "uiSupportedActions": [
                        "SELECT"
                      ]
                    },
                    {
                      "entity": {
                        "type": "AMAZON.Thing",
                        "name": {
                          "value": "季节和剧集"
                        },
                        "externalIds": {
                          "entityId": "webPageButton-002"
                        }
                      },
                      "elementId": "element-012",
                      "uiSupportedActions": [
                        "SELECT"
                      ]
                    },
                    {
                      "entity": {
                        "type": "AMAZON.Thing",
                        "name": {
                          "value": "添加到观看列表"
                        },
                        "externalIds": {
                          "entityId": "webPageButton-003"
                        }
                      },
                      "elementId": "element-013",
                      "uiSupportedActions": [
                        "SELECT"
                      ]
                    },
                    {
                      "entity": {
                        "type": "AMAZON.Thing",
                        "name": {
                          "value": "更多观看方式"
                        },
                        "externalIds": {
                          "entityId": "webPageButton-003"
                        }
                      },
                      "elementId": "element-013",
                      "uiSupportedActions": [
                        "SELECT"
                      ]
                    },                    
                    {
                      "entity": {
                        "type": "AMAZON.Thing",
                        "name": {
                          "value": "客户也观看了"
                        },
                        "externalIds": {
                          "entityId": "webPageButton-004"
                        }
                      },
                      "elementId": "element-014",
                      "uiSupportedActions": [
                        "SELECT"
                      ]
                    },
                  ]
                }
              ]
            },
            "timeOfSample": "2017-02-03T16:20:50.52Z",
            "uncertaintyInMilliseconds": 0
          },
          {
            "namespace": "Alexa.UIController",
            "name": "focusedUIElement",
            "value": {
              "scene": {
                "sceneId": "scene-id-001"
              },
              "element": {
                "entity": {
                  "type": "AMAZON.Thing",
                  "name": {
                    "value": "立即使用Prime观看"
                  },
                  "externalIds": {
                    "entityId": "webPageButton-003"
                  }
                },
                "elementId": "element-013",
                "uiSupportedActions": [
                  "SELECT"
                ]
              }
            },
            "timeOfSample": "2017-02-03T16:20:50.52Z",
            "uncertaintyInMilliseconds": 0
          }
        ]
      }
    }
  }
}
客户表述: “Alexa, select this”(Alexa,选择此项)
{
    "directive": {
        "endpoint": {
            "cookie": {},
            "endpointId": "<目标终端的标识符>",
            "scope": {
                "token": "<OAuth2持有者令牌>",
                "type": "BearerToken"
            }
        },
        "header": {
            "correlationToken": "dFMb0z+PgpgdDmluhJ1LddFvSqZ/jCc8ptlAKulUj90jSqg==",
            "messageId": "9451490f-9457-4197-93be-200f9e37b776",
            "name": "DisplayDetails",
            "namespace": "Alexa.MediaDetailsNavigator",
            "payloadVersion": "3"
        },
        "payload": {
            "entity":
                {
                    "externalIds": {
                        "entityId": "video-001"
                    },
                    "value": "The Marvelous Mrs. Maisel",
                    "type": "Video"
                }
        }
    }
}
询问有关AMAZON.Thing项目的详细信息时的错误场景
在您发送的用户界面状态报告中,您可以使用不同的实体类型对屏幕上的元素分类。这些在UIController文档的Enum<EntityTypes>中进行了描述。如果客户询问有关归类为AMAZON.Thing的元素的更多详情,则不会发送MediaDetailsNavigator指令,因为AMAZON.Thing不是MediaDetailsNavigator支持的项目类型。
用户看到的屏幕:

{
  "context": {
    "properties": []
  },
  "event": {
    "header": {
      "messageId": "abc-123-def-456",
      "namespace": "Alexa",
      "name": "ChangeReport",
      "payloadVersion": "3"
    },
    "endpoint": {
      "scope": {
        "type": "BearerToken",
        "token": "access-token-from-Amazon"
      },
      "endpointId": "avl-endpoint-id-001"
    },
    "payload": {
      "change": {
        "cause": {
          "type": "PHYSICAL_INTERACTION"
        },
        "properties": [
          {
            "namespace": "Alexa.UIController",
            "name": "uiElements",
            "value": {
              "scene": {
                "sceneId": "scene-id-004"
              },
              "elements": [
                {
                  "entity": {
                    "type": "AMAZON.Thing"
                  },
                  "elementId": "uiNode-000",
                  "uiSupportedActions": [
                    "SCROLL_FORWARD",
                    "SCROLL_DOWN"
                  ],
                  "elements": [
                    {
                      "entity": {
                        "type": "AMAZON.Thing",
                        "name": {
                          "value": "Home"
                        }
                      },
                      "elementId": "uiNode-001",
                      "uiSupportedActions": [
                        "SELECT"
                      ]
                    },
                    {
                      "entity": {
                        "type": "AMAZON.Thing",
                        "name": {
                          "value": "Shows"
                        }
                      },
                      "elementId": "uiNode-002",
                      "uiSupportedActions": [
                        "SELECT"
                      ]
                    },
                    {
                      "entity": {
                        "type": "AMAZON.Thing",
                        "name": {
                          "value": "IMDB FREEDIVE MOVIES AND TV-FREE WITH ADS"
                        }
                      },
                      "elementId": "uiNode-010",
                      "uiSupportedActions": []
                    },
                    {
                      "entity": {
                        "type": "AMAZON.Thing",
                        "name": {
                          "value": "Captain Fantastic"
                        }
                      },
                      "elementId": "uiNode-011",
                      "uiSupportedActions": [
                        "SELECT"
                      ]
                    },
                    {
                      "entity": {
                        "type": "AMAZON.Thing",
                        "name": {
                          "value": "Fringe"
                        }
                      },
                      "elementId": "uiNode-012",
                      "uiSupportedActions": [
                        "SELECT"
                      ]
                    },
                    {
                      "entity": {
                        "type": "AMAZON.Thing",
                        "name": {
                          "value": "Drive"
                        }
                      },
                      "elementId": "uiNode-013",
                      "uiSupportedActions": [
                        "SELECT"
                      ]
                    },
                    {
                      "entity": {
                        "type": "AMAZON.Thing",
                        "name": {
                          "value": "Forte"
                        }
                      },
                      "elementId": "uiNode-014",
                      "uiSupportedActions": [
                        "SELECT"
                      ]
                    },
                    {
                      "entity": {
                        "type": "AMAZON.Thing",
                        "name": {
                          "value": "Padington"
                        }
                      },
                      "elementId": "uiNode-015",
                      "uiSupportedActions": [
                        "SELECT"
                      ]
                    },
                  ]
                }
              ]
            },
            "timeOfSample": "2017-02-03T16:20:50.52Z",
            "uncertaintyInMilliseconds": 0
          }
        ]
      }
    }
  }
}
客户表述: “Alexa, select captain fantastic”(Alexa,选择captain fantastic)
由于聚焦的用户界面元素类型为AMAZON.Thing,并且这些实体类型不支持“显示详细信息”,因此未发送任何指令。应向客户发送一条表明这点的适当消息。
示例应用集成
您可以在云端示例应用中找到MediaDetailsNavigator的集成示例。示例应用包含Lambda代码,该代码演示如何使用MediaDetailsNavigator的Discover指令声明支持,以及如何处理MediaDetailsNavigator发送的DisplayDetails指令。
以下部分包含示例应用中DisplayDetails指令的详细用例。您无需实现任何类或方法即可测试示例应用。以下代码片段向您展示应在何处实现以及应如何使用所需的方法。您需要在应用代码中使用自己的逻辑。
要使用示例应用进行测试,请更改任何屏幕的用户界面内容,并使用Alexa测试以新用户界面内容为目标的语音。
显示详细信息指令
示例应用通过Lambda接收来自Alexa的指令。在onMessage方法中,该指令名为DisplayDetails。
protected void onMessage(final Intent intent) {
    Log.d(TAG, MessageFormat.format("Recieved a message from ADM: {0}", intent.toString()));
    
    //...
    else if ("DisplayDetails".equals(directiveName)) {
                // 检查json对象
                if (!jsonTree.isJsonObject()) {
                    // 无效消息JSON
                    Log.e(TAG, "Invalid message JSON");
                    return;
                }
                // 提取底层指令和有效负载
                final JsonObject jsonObject = jsonTree.getAsJsonObject();
                final JsonObject jDirective = jsonObject.get("directive").getAsJsonObject();
                final JsonElement jPayload = jDirective.get("payload");
                // 检查有效负载
                if (jPayload == null || !jPayload.isJsonObject()) {
                    // 无效的有效负载
                    Log.e(TAG, "Invalid payload; payload is null or not a JsonObject");
                    return;
                }
                final String jPayloadString = jPayload.getAsJsonObject().toString();
                final MediaDetailsElement mediaDetailsElement = gson.fromJson(jPayloadString, MediaDetailsElement.class);
                Log.d(TAG, "The MediaDetailsNavigator directive is " + mediaDetailsElement);
                // 验证指令
                if (!isMediaDetailsElementValid(mediaDetailsElement)) {
                    Log.e(TAG, "The received MediaDetailsElement directive is invalid.Cannot process it.");
                    return;
                }
                final Intent mediaDetailsIntent = new Intent();
                final String currentSceneId = getCurrentSceneId();
                final String packageName = FireTVApp.getInstance().getPackageName();
                if (HOME_BROWSER_SCENE_IDENTIFIER.equals(currentSceneId)) {
                    Log.d(TAG, MessageFormat.format("Setting the destination of mediaDetailsElement intent to Home Screen: {0}",
                            MainActivity.class.getName()));
                    mediaDetailsIntent.setClassName(packageName, MainActivity.class.getName());
                } else if (VIDEO_DETAIL_SCENE_IDENTIFIER.equals(currentSceneId)) {
                    Log.d(TAG, MessageFormat.format("Setting the destination of mediaDetailsElement intent to Detail Screen: {0}",
                            DetailsActivity.class.getName()));
                    mediaDetailsIntent.setClassName(packageName, DetailsActivity.class.getName());
                } else {
                    Log.w(TAG, MessageFormat.format("Current screen does not have items to display details of.Current scene: {0}", currentSceneId));
                    return;
                }
                mediaDetailsIntent.setAction(ACTION_ON_MEDIA_DETAILS);
                mediaDetailsIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
                // 将实体中的条目添加到意图
                mediaDetailsIntent.putExtra(EXTRA_MEDIA_DETAILS_NAVIGATOR_TYPE, mediaDetailsElement.getEntity().getType());
                mediaDetailsIntent.putExtra(EXTRA_MEDIA_DETAILS_NAVIGATOR_VALUE, mediaDetailsElement.getEntity().getValue());
                final ExternalIds externalIds = mediaDetailsElement.getEntity().getExternalIds();
                if (externalIds != null) {
                    Log.d(TAG, MessageFormat.format("externalIds is present: {0}", externalIds));
                    mediaDetailsIntent.putExtra(EXTRA_MEDIA_DETAILS_NAVIGATOR_ENTITY_ID, externalIds.getEntityId());
                }
                Log.d(TAG, MessageFormat.format("Sending the mediaDetailsElement intent: {0}", mediaDetailsIntent));
                FireTVApp.getInstance().startActivity(mediaDetailsIntent);
                Log.d(TAG, "Finished processing the DisplayDetails directive");
            } else {
                Log.e(TAG, "Unknown directive received.");
            }
        }
    }
有关示例应用配置的更多详细信息,请参阅Alexa.UIController接口 (VSK Fire TV)。
Last updated: 2021年10月13日

