RewardedVideoPlayer

RewardedVideoPlayer

激励视频播放器,封装激励视频加载、播放时序,详见[基础能力] 激励视频播放器

Constructor

new RewardedVideoPlayer(adUnitId)

Source:

构造函数

Parameters:
Name Type Description
adUnitId string

广告位id

Members

loadState

Source:

获取当前加载状态:notStart-未开始 | notSupport-版本过低不支持 | loading-加载中 | failed-加载失败 | loaded-加载成功

Methods

handlePageChange(preloadopt)

Source:

切换页面时原生视频实例失效,故每次onShow需重新初始化

Parameters:
Name Type Attributes Default Description
preload boolean <optional>
true

是否需要预加载视频:true-开始预加载 | false-不进行预加载(后续可手动调用load()决定加载时机)

(async) load(resetopt)

Source:

开始加载视频

Parameters:
Name Type Attributes Default Description
reset boolean <optional>
false

是否需要重置:true-强制重新加载 | false-可复用已有视频

onLoadStateChange(handler)

Source:

监听加载状态变化,用于展示/隐藏入口等

Example
rewardedVideoPlayer.onLoadStateChange(({state})=>{
 console.log('state', state); //加载状态,详见RewardedVideoPlayer#loadState
})
Parameters:
Name Type Description
handler function

监听函数

(async) play() → {object}

Source:

开始播放视频

Returns:

播放结果 {
code: 0, //是否正常:0-正常播放,其它-播放异常(微信版本过低/视频加载失败/其它异常情况)
errMsg: '', //异常提示信息
isEnded: true, //(正常时)是否观看完整
}

Type
object