Smart Home TransportControl Trait 架构

action.devices.traits.TransportControl - 此 trait 适用于能够控制媒体播放的设备(例如,在音乐暂停时继续播放)。

设备属性

具有此 trait 的设备可能会在 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"
  ]
}

设备状态

无。

设备命令

具有此 trait 的设备可能会在 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 整数

必填。

要跳转的前进(正整数)或后退(负整数)毫秒数。

示例

快进 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 布尔值

必填。

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

isSingle 布尔值

(默认值: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": {}
}

设备错误

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