# setCallback ^7.8

获取视频、音频播放回调

# 请求参数

N/A

# 接口调用示例

this.$bridge.setCallback(
  (res) => {
    console.log(res)
  },
  (err) => {
    console.log(err)
  }
)
1
2
3
4
5
6
7
8

# 返回参数

Prop Type Required Default Comment
status String Y N/A 播放状态。start:开始播放,play:播放中,pause:暂停,error: 错误,seek: 快进,complete: 完成,stop: 停止
url String Y N/A 当前播放的链接地址
current Number Y N/A 当前播放进度,单位毫秒
duration Number Y N/A 音频总长,单位毫秒
percent Number Y N/A 当前播放进度比例, 进度范围:0~1.0
code Number N N/A 状态码
msg String N N/A 状态信息

# 接口返回示例

// 成功回调
{
  duration: 15678,
  current: 14933,
  percent: 0.9524812,
  url: "/storage/emulated/0/Android/data/com.midea.ai.appliances/files/WeexApp/test_jack_record.wav",
  status: "play"
}

// 失败回调
{
  code: -1,
  msg: '本地文件不存在'
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14

# FAQ

TIP

  1. 需要用 callback 而非 promise 方式调用
  2. play, stop, seek, pause, loop, getDuration 这几个接口的统一回调函数。 需要回调函数时,需要先注册 setCallback
更新时间: 10/27/2022, 2:33:23 PM