# Media Command
# ControlMedia
该指令适用在媒体内容上执行动作,以达到完成功能切换的目的
property | default | description |
---|---|---|
type | ControlMedia | 指令类型,此处应为:ControlMedia |
componentId | - | 指定指令需要作用到的组件id |
command | - | 要执行的具体操作,可选值如下表 |
# command 参数枚举类型
componetType | command | description |
---|---|---|
Video | next | 下一个 |
Video | previous | 上一个 |
Video | play | 播放中 |
Video | pause | 暂停 |
Video | end | 播放结束 |
Audio | next | 下一个 |
Audio | previous | 上一个 |
Audio | play | 播放中 |
Audio | pause | 暂停 |
Audio | end | 播放结束 |
Timer | reset | 重置定时器 |
Timer | pause | 暂停定时器 |
Timer | play | 执行定时器 |
Counter | reset | 重置计时器 |
Counter | pause | 暂停计时器 |
Counter | play | 执行计时器 |
FrameAnimation | reset | 重置逐帧动画 |
FrameAnimation | pause | 暂停逐帧动画 |
FrameAnimation | play | 执行逐帧动画 |
# 消息样例
{
"type": "ControlMedia",
"componentId": "{{STRING}}",
"delay": {{INTEGER}},
"dWhen": "{{STRING}}",
"command": "{{ENUM}}"
}
# 参数说明
- type 固定 ControlMedia
- componentId 通过 DPL.RenderDocument 返回的数据中定义的对应的组件 id
- (optional) delay
- 指令在端上的延迟执行时间,单位毫秒,默认为 0
- (optional) dWhen
- command
Video 组件示例
- play 功能:开始播放当前资源(如果当前视频没有播放,command 设置为 play 时则播放器会触发 onPlay 事件开始播放资源),示例如下:
{ "type": "ControlMedia", "componentId": "myVideoPlayer", "command": "play" }
- pause 功能:暂停播放当前资源(如果当前视频正在播放,command 设置为 pause 时则播放器会触发 onPause 事件,暂停播放资源),示例如下:
{ "type": "ControlMedia", "componentId": "myVideoPlayer", "command": "pause" }
- end 功能:停止播放当前资源(如果当前视频正在播放,command 设置为 end 时则播放器会触发 onPause 事件,停止播放资源),示例如下:
{ "type": "ControlMedia", "componentId": "myVideoPlayer", "command": "end" }
- previous 功能:播放前一个资源(如果command设置为 previous 时,则播放器会触发 onPrevious 事件,播放上一个资源),示例如下:
{ "type": "ControlMedia", "componentId": "myVideoPlayer", "command": "previous" }
- next 功能:播放下一个资源(如果command设置为 next 时,则播放器会触发 onNext 事件,播放下一个资源),示例如下:
{ "type": "ControlMedia", "componentId": "myVideoPlayer", "command": "next" }
Audio 组件示例同上
Timer 组件示例
- reset 功能: 重置定时器
{ "type": "ControlMedia", "componentId": "myTimer", "command": "reset" }
- play 功能: 播放执行定时器
{ "type": "ControlMedia", "componentId": "myTimer", "command": "play" }
- pause 功能: 暂停定时器
{ "type": "ControlMedia", "componentId": "myTimer", "command": "pause" }
Counter 组件同上
FrameAnimation 组件同上