# playAudio ^6.8
播放音频。支持远程 url 和本地相对路径(即在 WeexApp 目录下的文件)。 美的美居 v8.12 支持久回调。
# 请求参数
Prop | Type | Required | Default | Comment |
---|---|---|---|---|
url | String | Y | '' | 播放录音的地址 |
loop | Boolean | N | false | 是否循环播放 |
# 接口调用示例
let params = {
url: '/test_jack_record.wav',
loop: false,
}
this.$bridge
.playAudio(params)
.then((res) => {
this.$alert(res)
})
.catch((err) => {
this.$toast(err)
})
// v8.12 以上支持回调传入,将会执行两次回调(开始播放和结束播放时触发回调)
this.$brdige.playAudio(
params,
(res) => {
this.$alert(res)
},
(err) => {
this.$toast(err)
}
)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# 返回参数
- 成功时返回
Prop | Type | Required | Default | Comment |
---|---|---|---|---|
code | Number | Y | N/A | 返回码。0:播放成功, 1:播放完成,-1001:(缺少参数 params, 缺少参数 url,参数 url 不能为空) |
msg | String | Y | N/A | 返回信息 |
# 返回示例
// 成功返回
{
code: 0,
msg: "success"
}
// 失败返回
{
code -1001,
msg: '缺少参数url, 参数url不能为空'
}
1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11