属性

    string src

    音频资源的地址,用于直接播放。2.2.3 开始支持云文件ID

    number startTime

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

    boolean autoplay

    是否自动开始播放,默认为

    boolean loop

    是否循环播放,默认为

    boolean obeyMuteSwitch

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

    number volume

    音量。范围 0~1。默认为 1

    number duration

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

    number currentTime

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

    boolean paused

    当前是是否暂停或停止状态(只读)

    number buffered

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

    方法

    InnerAudioContext.play()

    播放

    InnerAudioContext.pause()
    InnerAudioContext.stop()

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

    InnerAudioContext.seek(number position)

    跳转到指定位置

    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)

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

    示例代码