Appearance
其他事件
注意
该事件为订阅异步回调事件
用法示例
js
//事件
onEvent(e) {
console.log(e.detail)
}js
function onEvent(e : JSONObject) {
console.log("onEvent:" + e.toJSONString())
}回调示例
json
{
"type": "onStateChanged",
"data": {
"data": {
"playerId": "ApsaraVideoPlayer@5c1d95",
"newState": "INITIALIZED",
"oldState": "PREPARING"
},
"message": "",
"code": 0
}
}json
{
"type": "onPrepared",
"data": {
"data": {
"playerId": "ApsaraVideoPlayer@ebb0590",
"duration": 160046
},
"message": "",
"code": 0
}
}json
{
"type": "onFirstFrameRendered",
"data": {
"data": {
"playerId": "ApsaraVideoPlayer@471ddd6"
},
"message": "",
"code": 0
}
}json
{
"type": "onVideoSizeChanged",
"data": {
"data": {
"playerId": "ApsaraVideoPlayer@764b60a",
"height": 360,
"width": 640
},
"message": "",
"code": 0
}
}json
{
"type": "onInfo",
"data": {
"data": {
"playerId": "ApsaraVideoPlayer@d91cac",
"bufferedPosition": 53943,
"currentPosition": 3924,
"duration": 160046
},
"message": "",
"code": 0
}
}json
{
"type": "onError",
"data": {
"data": {
"playerId": "ApsaraVideoPlayer@d91cac",
"errorCode": 10001,
"errorMsg": "错误信息描述"
},
"message": "",
"code": 0
}
}json
{
"type": "LoadingBegin",
"data": {
"data": {
"playerId": "ApsaraVideoPlayer@d91cac"
},
"message": "",
"code": 0
}
}json
{
"type": "LoadingProgress",
"data": {
"data": {
"playerId": "ApsaraVideoPlayer@d91cac",
"netSpeed": 5.55,
"percent": 50
},
"message": "",
"code": 0
}
}json
{
"type": "LoadingEnd",
"data": {
"data": {
"playerId": "ApsaraVideoPlayer@d91cac"
},
"message": "",
"code": 0
}
}json
{
"type": "onSetSpeedCompleted",
"data": {
"data": {
"playerId": "ApsaraVideoPlayer@21cba1f",
"speed": 1.5
},
"message": "",
"code": 0
}
}json
{
"type": "onSnapshotCompleted",
"data": {
"data": {
"playerId": "ApsaraVideoPlayer@20d0945",
"height": 975,
"width": 1224,
"path": "/storage/emulated/0/Android/data/uni.app.UNI3EE9858/files/AliPlayerKit/IMG_20260601_120847.jpg",
"result": true
},
"message": "",
"code": 0
}
}json
{
"type": "onSetLoopCompleted",
"data": {
"data": {
"playerId": "ApsaraVideoPlayer@673f461",
"loop": true
},
"message": "",
"code": 0
}
}json
{
"type": "onSetMuteCompleted",
"data": {
"data": {
"playerId": "ApsaraVideoPlayer@7f1af74",
"mute": true
},
"message": "",
"code": 0
}
}json
{
"type": "onSetScaleTypeCompleted",
"data": {
"data": {
"playerId": "ApsaraVideoPlayer@de2e541",
"scaleType": "CENTER_CROP"
},
"message": "",
"code": 0
}
}json
{
"type": "onSetMirrorTypeCompleted",
"data": {
"data": {
"playerId": "ApsaraVideoPlayer@1ff35ee",
"mirrorType": "HORIZONTAL"
},
"message": "",
"code": 0
}
}json
{
"type": "onSetRotationCompleted",
"data": {
"data": {
"playerId": "ApsaraVideoPlayer@8b6fc10",
"rotation": "DEGREE_90"
},
"message": "",
"code": 0
}
}json
{
"type": "onTrackQualityListUpdated",
"data": {
"data": {
"playerId": "ApsaraVideoPlayer@4fd6c3c",
"trackQualityList": [
{
"index": 0,
"height": 360,
"type": "VOD",
"width": 640
},
{
"index": 1,
"height": 720,
"type": "VOD",
"width": 1280
},
{
"index": 2,
"height": 1080,
"type": "VOD",
"width": 1920
}
]
},
"message": "",
"code": 0
}
}json
{
"type": "onTrackSelected",
"data": {
"data": {
"playerId": "ApsaraVideoPlayer@47e86d3",
"trackIndex": 1
},
"message": "",
"code": 0
}
}回调说明
| 参数名 | 参数类型 | 参数描述 |
|---|---|---|
| type | String | 事件类型,请参考下方说明 |
| data | Object | 事件数据 |
| data.code | Integer | 事件结果类型,0.成功,其他:失败 |
| data.data | Integer | 事件结果数据 |
| data.message | String | 事件结果消息 |
回调事件类型说明
播放状态变化
类型名称
StateChanged
回调说明
| 参数名 | 参数类型 | 参数描述 |
|---|---|---|
| message | String | 消息提示 |
| data | Object | 数据对象 |
| data.playerId | String | 播放器唯一标识 |
| data.newState | String | 新状态 |
| data.oldState | String | 旧状态 |
| code | Integer | 返回类型,0.成功,其他:失败 |
播放器准备完成
类型名称
Prepared
回调说明
| 参数名 | 参数类型 | 参数描述 |
|---|---|---|
| message | String | 消息提示 |
| data | Object | 数据对象 |
| data.playerId | String | 播放器唯一标识 |
| data.duration | Integer | 视频总时长,单位:毫秒 |
| code | Integer | 返回类型,0.成功,其他:失败 |
首帧渲染完成
类型名称
FirstFrameRendered
回调说明
| 参数名 | 参数类型 | 参数描述 |
|---|---|---|
| message | String | 消息提示 |
| data | Object | 数据对象 |
| data.playerId | String | 播放器唯一标识 |
| code | Integer | 返回类型,0.成功,其他:失败 |
视频尺寸变化
类型名称
VideoSizeChanged
回调说明
| 参数名 | 参数类型 | 参数描述 |
|---|---|---|
| message | String | 消息提示 |
| data | Object | 数据对象 |
| data.playerId | String | 播放器唯一标识 |
| data.width | Integer | 当前尺寸宽度 |
| data.height | Integer | 当前尺寸高度 |
| code | Integer | 返回类型,0.成功,其他:失败 |
播放信息更新
类型名称
Info
回调说明
| 参数名 | 参数类型 | 参数描述 |
|---|---|---|
| message | String | 消息提示 |
| data | Object | 数据对象 |
| data.playerId | String | 播放器唯一标识 |
| data.bufferedPosition | Integer | 缓冲的时长,单位:毫秒 |
| data.currentPosition | Integer | 当前播放时长,单位:毫秒 |
| data.duration | Integer | 视频总时长,单位:毫秒 |
| code | Integer | 返回类型,0.成功,其他:失败 |
错误事件
类型名称
Error
回调说明
| 参数名 | 参数类型 | 参数描述 |
|---|---|---|
| message | String | 消息提示 |
| data | Object | 数据对象 |
| data.playerId | String | 播放器唯一标识 |
| data.errorCode | Integer | 错误信息代码 |
| data.errorMsg | String | 错误信息描述 |
| code | Integer | 返回类型,0.成功,其他:失败 |
开始加载
类型名称
LoadingBegin
回调说明
| 参数名 | 参数类型 | 参数描述 |
|---|---|---|
| message | String | 消息提示 |
| data | Object | 数据对象 |
| data.playerId | String | 播放器唯一标识 |
| code | Integer | 返回类型,0.成功,其他:失败 |
加载进度
类型名称
LoadingProgress
回调说明
| 参数名 | 参数类型 | 参数描述 |
|---|---|---|
| message | String | 消息提示 |
| data | Object | 数据对象 |
| data.playerId | String | 播放器唯一标识 |
| data.netSpeed | Float | 网络速度 |
| data.percent | Integer | 当前进度百分比 |
| code | Integer | 返回类型,0.成功,其他:失败 |
加载结束
类型名称
LoadingEnd
回调说明
| 参数名 | 参数类型 | 参数描述 |
|---|---|---|
| message | String | 消息提示 |
| data | Object | 数据对象 |
| data.playerId | String | 播放器唯一标识 |
| code | Integer | 返回类型,0.成功,其他:失败 |
设置速度完成
类型名称
SetSpeedCompleted
回调说明
| 参数名 | 参数类型 | 参数描述 |
|---|---|---|
| message | String | 消息提示 |
| data | Object | 数据对象 |
| data.playerId | String | 播放器唯一标识 |
| data.speed | Float | 当前播放速度 |
| code | Integer | 返回类型,0.成功,其他:失败 |
截图完成
类型名称
SnapshotCompleted
回调说明
| 参数名 | 参数类型 | 参数描述 |
|---|---|---|
| message | String | 消息提示 |
| data | Object | 数据对象 |
| data.playerId | String | 播放器唯一标识 |
| data.width | Integer | 截图宽度,截图成功时返回截图宽度,截图失败时返回 0 |
| data.height | Integer | 截图高度,截图成功时返回截图高度,截图失败时返回 0 |
| data.path | String | 截图文件路径,截图成功时返回截图文件路径,截图失败时返回 null |
| data.result | Boolean | 截图结果,true 表示截图成功,false 表示截图失败 |
| code | Integer | 返回类型,0.成功,其他:失败 |
设置循环完成
类型名称
SetLoopCompleted
回调说明
| 参数名 | 参数类型 | 参数描述 |
|---|---|---|
| message | String | 消息提示 |
| data | Object | 数据对象 |
| data.playerId | String | 播放器唯一标识 |
| data.loop | Boolean | 是否循环播放 |
| code | Integer | 返回类型,0.成功,其他:失败 |
设置静音完成
类型名称
SetMuteCompleted
回调说明
| 参数名 | 参数类型 | 参数描述 |
|---|---|---|
| message | String | 消息提示 |
| data | Object | 数据对象 |
| data.playerId | String | 播放器唯一标识 |
| data.mute | String | 是否静音 |
| code | Integer | 返回类型,0.成功,其他:失败 |
设置填充模式完成
类型名称
SetScaleTypeCompleted
回调说明
| 参数名 | 参数类型 | 参数描述 |
|---|---|---|
| message | String | 消息提示 |
| data | Object | 数据对象 |
| data.playerId | String | 播放器唯一标识 |
| data.scaleType | String | 当前填充模式 |
| code | Integer | 返回类型,0.成功,其他:失败 |
设置镜像完成
类型名称
SetMirrorTypeCompleted
回调说明
| 参数名 | 参数类型 | 参数描述 |
|---|---|---|
| message | String | 消息提示 |
| data | Object | 数据对象 |
| data.playerId | String | 播放器唯一标识 |
| data.mirrorType | String | 当前镜像 |
| code | Integer | 返回类型,0.成功,其他:失败 |
设置旋转完成
类型名称
SetRotationCompleted
回调说明
| 参数名 | 参数类型 | 参数描述 |
|---|---|---|
| message | String | 消息提示 |
| data | Object | 数据对象 |
| data.playerId | String | 播放器唯一标识 |
| data.rotation | String | 当前旋转角度 |
| code | Integer | 返回类型,0.成功,其他:失败 |
清晰度列表更新
类型名称
onTrackQualityListUpdated
回调说明
| 参数名 | 参数类型 | 参数描述 |
|---|---|---|
| message | String | 消息提示 |
| data | Object | 数据对象 |
| data.playerId | String | 播放器唯一标识 |
| data.trackQualityList | Object[] | 清晰度列表 |
| data.trackQualityList.index | Integer | 清晰度索引 |
| data.trackQualityList.height | Integer | 清晰度高度 |
| data.trackQualityList.type | String | 清晰度类型 |
| data.trackQualityList.width | Integer | 清晰度宽度 |
| code | Integer | 返回类型,0.成功,其他:失败 |
清晰度选择完成
类型名称
TrackSelected
回调说明
| 参数名 | 参数类型 | 参数描述 |
|---|---|---|
| message | String | 消息提示 |
| data | Object | 数据对象 |
| data.playerId | String | 播放器唯一标识 |
| data.trackIndex | Integer | 清晰度列表 |
| data.trackQualityList.index | Integer | 清晰度列表索引 |
| code | Integer | 返回类型,0.成功,其他:失败 |

