欢迎使用 Google Home 开发者中心,这是一个学习如何开发智能家居 Action 的新平台。注意:构建 Action 的工作仍需在 Actions 控制台中完成。

智能家居 TransportControl 特征架构

action.devices.traits.TransportControl - 此特征用于能够控制媒体播放的设备(例如,在暂停期间恢复播放音乐)。

设备属性

具有此特征的设备可以在 SYNC 操作中报告以下属性。如需详细了解如何处理 SYNC intent,请参阅 intent 执行方式

属性 类型 说明
transportControlSupportedCommands 数组

必填。

描述此设备上支持的传输控制命令的字符串列表。

[item, ...] String

支持的命令。

支持的值:

CAPTION_CONTROL
NEXT
PAUSE
PREVIOUS
RESUME
SEEK_RELATIVE
SEEK_TO_POSITION
SET_REPEAT
SHUFFLE
STOP

示例

支持播放命令的设备

{
  "transportControlSupportedCommands": [
    "NEXT",
    "PREVIOUS",
    "PAUSE",
    "STOP",
    "RESUME"
  ]
}

设备状态

无。

设备命令

具有此特征的设备可能会在 EXECUTE 操作中响应以下命令。如需详细了解如何处理 EXECUTE intent,请参阅 intent 执行方式

action.devices.commands.mediaStop

暂停媒体播放。

此命令需要以下属性:
{
  "transportControlSupportedCommands": [
    "STOP"
  ]
}

参数

参数 类型 说明

没有属性

示例

无参数

{
  "command": "action.devices.commands.mediaStop",
  "params": {}
}

action.devices.commands.mediaNext

跳到下一个媒体项。

此命令需要以下属性:
{
  "transportControlSupportedCommands": [
    "NEXT"
  ]
}

参数

参数 类型 说明

没有属性

示例

无参数

{
  "command": "action.devices.commands.mediaNext",
  "params": {}
}

action.devices.commands.mediaPrevious

跳到上一个媒体项。

此命令需要以下属性:
{
  "transportControlSupportedCommands": [
    "PREVIOUS"
  ]
}

参数

参数 类型 说明

没有属性

示例

无参数

{
  "command": "action.devices.commands.mediaPrevious",
  "params": {}
}

action.devices.commands.mediaPause

暂停媒体播放。

此命令需要以下属性:
{
  "transportControlSupportedCommands": [
    "PAUSE"
  ]
}

参数

参数 类型 说明

没有属性

示例

无参数

{
  "command": "action.devices.commands.mediaPause",
  "params": {}
}

action.devices.commands.mediaResume

继续播放媒体。

此命令需要以下属性:
{
  "transportControlSupportedCommands": [
    "RESUME"
  ]
}

参数

参数 类型 说明

没有属性

示例

无参数

{
  "command": "action.devices.commands.mediaResume",
  "params": {}
}

action.devices.commands.mediaSeekRelative

跳转到相对位置。

此命令需要以下属性:
{
  "transportControlSupportedCommands": [
    "SEEK_RELATIVE"
  ]
}

参数

参数 类型 说明
relativePositionMs 整数

必填。

跳转的正向(毫秒)或向后(负 int)的毫秒数。

示例

快进 10 秒

{
  "command": "action.devices.commands.mediaSeekRelative",
  "params": {
    "relativePositionMs": 10000
  }
}

快退 10 秒

{
  "command": "action.devices.commands.mediaSeekRelative",
  "params": {
    "relativePositionMs": -10000
  }
}

action.devices.commands.mediaSeekToPosition

跳转到绝对位置。

此命令需要以下属性:
{
  "transportControlSupportedCommands": [
    "SEEK_TO_POSITION"
  ]
}

参数

参数 类型 说明
absPositionMs 整数

必填。

要搜索的精确位置的毫秒数。

示例

跳转到 30 秒

{
  "command": "action.devices.commands.mediaSeekToPosition",
  "params": {
    "absPositionMs": 30000
  }
}

action.devices.commands.mediaRepeatMode

设置重复播放模式。

此命令需要以下属性:
{
  "transportControlSupportedCommands": [
    "SET_REPEAT"
  ]
}

参数

参数 类型 说明
isOn Boolean

必填。

设为 true 可开启重复模式,设为 false 可关闭重复模式。

isSingle Boolean

(默认:false

如果指定,true 表示启用单项重复模式,false 表示开启常规重复模式(例如播放列表)。

示例

重复

{
  "command": "action.devices.commands.mediaRepeatMode",
  "params": {
    "isOn": true
  }
}

关闭重复播放

{
  "command": "action.devices.commands.mediaRepeatMode",
  "params": {
    "isOn": false
  }
}

重复播放单首曲目

{
  "command": "action.devices.commands.mediaRepeatMode",
  "params": {
    "isOn": true,
    "isSingle": true
  }
}

action.devices.commands.mediaShuffle

随机播放当前播放列表。

此命令需要以下属性:
{
  "transportControlSupportedCommands": [
    "SHUFFLE"
  ]
}

参数

参数 类型 说明

没有属性

示例

无参数

{
  "command": "action.devices.commands.mediaShuffle",
  "params": {}
}

action.devices.commands.mediaClosedCaptioningOn

开启字幕。

此命令需要以下属性:
{
  "transportControlSupportedCommands": [
    "CAPTION_CONTROL"
  ]
}

参数

参数 类型 说明
closedCaptioningLanguage String

字幕的语言或语言区域。

userQueryLanguage String

用户查询的语言或语言区域。

示例

开启英语字幕

{
  "command": "action.devices.commands.mediaClosedCaptioningOn",
  "params": {
    "closedCaptioningLanguage": "en"
  }
}

开启韩语字幕

{
  "command": "action.devices.commands.mediaClosedCaptioningOn",
  "params": {
    "closedCaptioningLanguage": "ko-KR"
  }
}

为美式英语开启韩语字幕,并允许用户查询

{
  "command": "action.devices.commands.mediaClosedCaptioningOn",
  "params": {
    "closedCaptioningLanguage": "ko-KR",
    "userQueryLanguage": "en-US"
  }
}

action.devices.commands.mediaClosedCaptioningOff

关闭字幕。

此命令需要以下属性:
{
  "transportControlSupportedCommands": [
    "CAPTION_CONTROL"
  ]
}

参数

参数 类型 说明

没有属性

示例

关闭字幕

{
  "command": "action.devices.commands.mediaClosedCaptioningOff",
  "params": {}
}

设备错误

查看错误和异常的完整列表。