微信小游戏开发文档-小游戏媒体API InnerAudioContext

2018-10-26 19:34 更新

InnerAudioContext

InnerAudioContext 实例,可通过 wx.createInnerAudioContext 接口获取实例。

属性

string src

音频资源的地址

boolean autoplay

是否自动播放

boolean loop

是否循环播放

boolean obeyMuteSwitch

是否遵循系统静音开关,当此参数为 false 时,即使用户打开了静音开关,也能继续发出声音

number duration

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

number currentTime

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

number duration

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

boolean paused

当前是是否暂停或停止状态,true 表示暂停或停止,false 表示正在播放

number buffered

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

number volume

音量。范围 0~1。

方法

InnerAudioContext.play()

播放

InnerAudioContext.pause()

暂停。暂停后的音频再播放会从暂停处开始播放

InnerAudioContext.pause()

停止。停止后的音频再播放会从头开始播放。

InnerAudioContext.seek(number position)

跳转到指定位置,单位 s

InnerAudioContext.destroy()

销毁当前实例

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)

监听音频播放错误事件

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)

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


以上内容是否对您有帮助:
在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号