Skip to content

方法事件

注意

方法事件为组件方法调用后异步回调事件

用法示例

js
//事件
onEventMethod(e) {
  console.log(e.detail)
}
js
function onEventMethod(e : JSONObject) {
  console.log("onEvent:" + e.toJSONString())
}

回调示例

json
{
  "type": "getVideoData",
  "data": {
    "data": {
      "playerId": "ApsaraVideoPlayer@4d18577",
      "autoPlay": true,
      "currentMirrorType": "NONE",
      "startTime": 0,
      "currentTrackIndex": 0,
      "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
        }
      ],
      "sceneType": "VOD",
      "duration": 160046,
      "videoSize": {
        "weight": 360,
        "width": 640
      },
      "videoSource": {
        "mediaId": "vidauth:004fc90fd71d71f0bf184531958c0402",
        "isValid": true,
        "sourceType": "VID_AUTH"
      },
      "currentSpeed": 1,
      "isFullscreen": false,
      "currentRotation": "DEGREE_0",
      "videoTitle": "Long Video",
      "isLoop": false,
      "currentPosition": 1323,
      "currentScaleType": "FIT_CENTER",
      "isMute": false,
      "playerState": "PLAYING",
      "isHardWareDecode": true,
      "isAllowedScreenSleep": false,
      "traceId": ""
    },
    "message": "",
    "code": 0
  }
}
json
{
    "type": "play",
    "data": {
        "data": {},
        "message": "",
        "code": 0
    }
}
json
{
    "type": "start",
    "data": {
        "data": {},
        "message": "",
        "code": 0
    }
}
json
{
    "type": "pause",
    "data": {
        "data": {},
        "message": "",
        "code": 0
    }
}
json
{
    "type": "stop",
    "data": {
        "data": {},
        "message": "",
        "code": 0
    }
}
json
{
    "type": "toggle",
    "data": {
        "data": {},
        "message": "",
        "code": 0
    }
}
json
{
    "type": "replay",
    "data": {
        "data": {},
        "message": "",
        "code": 0
    }
}
json
{
    "type": "seekTo",
    "data": {
        "data": {},
        "message": "",
        "code": 0
    }
}
json
{
    "type": "setSpeed",
    "data": {
        "data": {},
        "message": "",
        "code": 0
    }
}
json
{
    "type": "setLoop",
    "data": {
        "data": {},
        "message": "",
        "code": 0
    }
}
json
{
    "type": "setMute",
    "data": {
        "data": {},
        "message": "",
        "code": 0
    }
}
json
{
    "type": "setMirrorType",
    "data": {
        "data": {},
        "message": "",
        "code": 0
    }
}
json
{
    "type": "setRotation",
    "data": {
        "data": {},
        "message": "",
        "code": 0
    }
}
json
{
    "type": "snapshot",
    "data": {
        "data": {},
        "message": "",
        "code": 0
    }
}

回调说明

参数名参数类型参数描述
typeString事件类型,请参考下方说明
dataObject事件数据
data.codeInteger事件结果类型,0.成功,其他:失败
data.dataInteger事件结果数据
data.messageString事件结果消息

回调事件类型说明

获取视频数据

类型名称

getVideoData

回调说明

参数名参数类型参数描述
messageString消息提示
dataObject数据对象
data.playerIdString播放器唯一标识
data.autoPlayBoolean是否自动播放
data.currentMirrorTypeString当前镜像类型
data.startTimeInteger开始播放时间
data.currentTrackIndexInteger当前清晰度索引
data.trackQualityListObject[]清晰度列表
data.trackQualityList.indexInteger清晰度索引
data.trackQualityList.heightInteger清晰度高度
data.trackQualityList.typeString清晰度类型
data.trackQualityList.widthInteger清晰度宽度
data.sceneTypeString场景类型
data.durationInteger视频时长
data.videoSizeObject视频分辨率
data.videoSize.widthInteger分辨率的宽
data.videoSize.heightInteger分辨率的高
data.videoSourceObject视频源
data.videoSource.mediaIdString视频源唯一id
data.videoSource.isValidBoolean视频源是否有效
data.videoSource.sourceTypeBoolean视频源类型
data.currentSpeedFloat当前播放速度
data.isFullscreenBoolean是否全屏
data.currentRotationString当前视频旋转角度
data.videoTitleString视频标题
data.isLoopBoolean是否循环播放
data.currentPositionInteger当前播放的位置
data.currentScaleTypeString当前视频填充模式
data.isMuteBoolean是否静音
data.playerStateString播放状态,具体类型如下:
UNKNOWN:未知状态:播放器状态未知或未初始化
IDLE:空闲状态:播放器已创建但尚未初始化,或已释放资源
INITIALIZING:初始化中:播放器正在初始化,准备加载视频资源
INITIALIZED:已初始化:播放器已完成初始化,但尚未准备播放
PREPARING:准备中:播放器正在准备视频资源,解析视频信息
PREPARED:已准备:播放器已完成准备,可以开始播放
PLAYING:播放中:播放器正在播放视频
PAUSED:暂停:播放器已暂停播放
COMPLETED:播放完成:视频播放已完成
STOPPED:停止:播放器已停止播放
ERROR:错误:播放器发生错误
data.isHardWareDecodeBoolean是否启用硬解码
data.isAllowedScreenSleepBoolean是否启用屏幕休眠
data.traceIdString视频跟踪id
codeInteger返回类型,0.成功,其他:失败

播放下一个视频

类型名称

play

回调说明

参数名参数类型参数描述
messageString消息提示
dataObject数据对象
codeInteger返回类型,0.成功,其他:失败

开始播放

类型名称

start

回调说明

参数名参数类型参数描述
messageString消息提示
dataObject数据对象
codeInteger返回类型,0.成功,其他:失败

暂停播放

类型名称

pause

回调说明

参数名参数类型参数描述
messageString消息提示
dataObject数据对象
codeInteger返回类型,0.成功,其他:失败

停止播放

类型名称

stop

回调说明

参数名参数类型参数描述
messageString消息提示
dataObject数据对象
codeInteger返回类型,0.成功,其他:失败

播放/暂停切换

类型名称

toggle

回调说明

参数名参数类型参数描述
messageString消息提示
dataObject数据对象
codeInteger返回类型,0.成功,其他:失败

重播

类型名称

replay

回调说明

参数名参数类型参数描述
messageString消息提示
dataObject数据对象
codeInteger返回类型,0.成功,其他:失败

跳转到指定位置

类型名称

seekTo

回调说明

参数名参数类型参数描述
messageString消息提示
dataObject数据对象
codeInteger返回类型,0.成功,其他:失败

设置播放速度

类型名称

setSpeed

回调说明

参数名参数类型参数描述
messageString消息提示
dataObject数据对象
codeInteger返回类型,0.成功,其他:失败

设置循环播放

类型名称

setLoop

回调说明

参数名参数类型参数描述
messageString消息提示
dataObject数据对象
codeInteger返回类型,0.成功,其他:失败

设置静音

类型名称

setMute

回调说明

参数名参数类型参数描述
messageString消息提示
dataObject数据对象
codeInteger返回类型,0.成功,其他:失败

设置渲染填充模式

类型名称

setScaleType

回调说明

参数名参数类型参数描述
messageString消息提示
dataObject数据对象
codeInteger返回类型,0.成功,其他:失败

设置镜像模式

类型名称

setMirrorType

回调说明

参数名参数类型参数描述
messageString消息提示
dataObject数据对象
codeInteger返回类型,0.成功,其他:失败

设置旋转角度

类型名称

setRotation

回调说明

参数名参数类型参数描述
messageString消息提示
dataObject数据对象
codeInteger返回类型,0.成功,其他:失败

截图

类型名称

snapshot

回调说明

参数名参数类型参数描述
messageString消息提示
dataObject数据对象
codeInteger返回类型,0.成功,其他:失败