纯音频播放器 API

JessibucaProAudio(options)

options 支持的参数有:

decoder

  • 类型string
  • 默认值decoder-pro-audio-player.js
  • 用法

worker地址

默认引用的是根目录下面的decoder-pro-audio-player.js文件 ,decoder-pro-audio-player.js 与 decoder-pro-audio.wasm文件必须是放在同一个目录下面。

debug

JessibucaProVideo

debugLevel

JessibucaProVideo

isFlv

JessibucaProVideo

isNotMute

JessibucaProVideo

videoBuffer

JessibucaProVideo

loadingTimeout

JessibucaProVideo

heartTimeout

JessibucaProVideo

loadingTimeoutReplay

JessibucaProVideo

heartTimeoutReplay

JessibucaProVideo

loadingTimeoutReplayTimes

JessibucaProVideo

heartTimeoutReplayTimes

  • 类型number
  • 默认值3
  • 用法: heartTimeoutReplay 重试次数

JessibucaProVideo

weiXinInAndroidAudioBufferSize

JessibucaProVideo

audioEngine

JessibucaProVideo

supportLockScreenPlayAudio

JessibucaProVideo

isDecoderUseCDN

JessibucaProVideo

方法

play([url])

  • 参数

    • {string} url
  • 返回

    • {Promise}
  • 用法: 播放音频


jessibucaProAudio.play('url').then(() => {
    console.log('play success')
}).catch((e) => {
    console.log('play error', e)
})
//
jessibucaProAudio.play().then(() => {
    console.log('play success')
}).catch((e) => {
    console.log('play error', e)
})

setDebug(flag)

JessibucaProVideo

updateDebugLevel(level)

JessibucaProVideo

mute()

JessibucaProVideo

cancelMute()

JessibucaProVideo

pause()

JessibucaProVideo

setVolume(value)

JessibucaProVideo

getVolume()

JessibucaProVideo

audioResume()

JessibucaProVideo

事件

timeUpdate

JessibucaProVideo

audioInfo

JessibucaProVideo

error

错误信息

目前已有的错误信息:

  • JessibucaProAudio.ERROR.playError ;播放错误,url 为空的时候,调用play方法
  • JessibucaProAudio.ERROR.fetchError ;http 请求失败
  • JessibucaProAudio.ERROR.websocketError; websocket 请求失败
  • JessibucaProAudio.ERROR.audioChannelError ;音频通道错误

jessibucaProAudio.on("error", function (error) {
    if (error === JessibucaProAudio.ERROR.fetchError) {
        //
    } else if (error === JessibucaProAudio.ERROR.webcodecsH265NotSupport) {
        //
    }
    console.log('error:', error)
})

// or
jessibucaProAudio.on(jessibucaProAudio.EVENTS.error, function (error) {
    if (error === jessibucaProAudio.ERROR.fetchError) {
        //
    } else if (error === jessibucaProAudio.ERROR.webcodecsH265NotSupport) {
        //
    }
    console.log('error:', error)
})

kBps

JessibucaProVideo

loadingTimeout

JessibucaProVideo

loadingTimeoutRetryEnd

JessibucaProVideo

delayTimeout

JessibucaProVideo

delayTimeoutRetryEnd

JessibucaProVideo

play

JessibucaProVideo

pause

JessibucaProVideo

mute

JessibucaProVideo

stats

JessibucaProVideo

crashLog

触发播放器重播的时候,会抛出错误信息,方便业务层做错误上报

  • 回调参数
    • {object} data 错误信息内容

主要收集的数据有

  • url: 播放地址
  • type: 错误的类型
  • error: 错误信息
  • playType : 播放类型
  • demuxType:解封装类型
  • audioInfo : 音频信息 {encType,channels,sampleRate}
  • audioEngine :音频引擎
jessibucaProAudio.on('crashLog', (data) => {
    console.log('crashLog is', data);
})

// or
jessibucaProAudio.on(jessibucaProAudio.EVENTS.crashLog, (data) => {
    console.log('crashLog is', data);
})

websocketOpen

JessibucaProVideo

websocketClose

JessibucaProVideo

playFailedAndPaused

JessibucaProVideo

audioResumeState

JessibucaProVideo