指南 接口 其他

InnerAudioContext

String InnerAudioContext.src

音频资源的地址

Number InnerAudioContext.startTime

开始播放的位置(单位:s),默认为 0

Boolean InnerAudioContext.autoplay

是否自动播放,默认是 false

Boolean InnerAudioContext.loop

是否循环播放,默认是 false

Number InnerAudioContext.duration

获取当前音频的长度,单位 s。只有在当前有合法的 src 时返回

Number InnerAudioContext.currentTime

当前音频的播放位置,单位 s。只有在当前有合法的 src 时返回,时间不取整,保留小数点后 6 位(只读)

Boolean InnerAudioContext.paused

获取当前是是否暂停或停止状态,true 表示暂停或停止,false 表示正在播放(只读)

Number InnerAudioContext.volume

设置或获取音频的音量,范围 0~1

Number InnerAudioContext.buffered

音频缓冲的时间点,仅保证当前播放时间点到此时间点内容已缓冲(只读)

InnerAudioContext.play()

播放音频

InnerAudioContext.seek(Number position)

跳转到指定位置,单位 s

InnerAudioContext.pause()

暂停播放音频

InnerAudioContext.stop()

停止播放音频

InnerAudioContext.destroy()

销毁音频实例(但是 js 对象还会存在)

InnerAudioContext.onCanplay(Function callback)

监听音频进入可以播放状态的事件

InnerAudioContext.offCanplay(Function callback)

取消监听音频进入可以播放状态的事件

InnerAudioContext.onPlay(Function callback)

监听音频播放事件

InnerAudioContext.offPlay(Function callback)

取消监听音频播放事件

InnerAudioContext.onPause(Function callback)

监听音频暂停事件

InnerAudioContext.offPause(Function callback)

取消监听音频暂停事件

InnerAudioContext.onStop(Function callback)

监听音频停止事件

InnerAudioContext.offStop(Function callback)

取消监听音频停止事件

InnerAudioContext.onEnded(Function callback)

监听音频自然播放至结束的事件

InnerAudioContext.offEnded(Function callback)

取消监听音频自然播放至结束的事件

InnerAudioContext.onTimeUpdate(Function callback)

监听音频播放进度更新事件

InnerAudioContext.offTimeUpdate(Function callback)

取消监听音频播放进度更新事件

InnerAudioContext.onError(Function callback)

监听音频播放错误事件

callback参数Object res

属性类型说明
errCodenumber错误码

errCode 的合法值

说明
10001系统错误
10002网络错误
10003文件错误
10004格式错误
-1未知错误

InnerAudioContext.offError(Function callback)

取消监听音频播放错误事件

InnerAudioContext.onWaiting(Function callback)

监听音频加载中事件。当音频因为数据不足,需要停下来加载时会触发

InnerAudioContext.offWaiting(Function callback)

取消监听音频加载中事件。当音频因为数据不足,需要停下来加载时会触发

InnerAudioContext.onSeeking(Function callback)

监听音频进行跳转操作的事件

InnerAudioContext.offSeeking(Function callback)

取消监听音频进行跳转操作的事件

InnerAudioContext.onSeeked(Function callback)

监听音频完成跳转操作的事件

InnerAudioContext.offSeeked(Function callback)

取消监听音频完成跳转操作的事件

InnerAudioContext qg.createInnerAudioContext()

创建一个内部 audio 上下文 InnerAudioContext 对象。

条匹配 "" 的结果

    没有搜索到与 "" 相关的内容