|
初始化是这样:
sw_pb.init = function (params) {
console.log("播放器准备中: configPlayerView");
params.player_ch = api.require('TXLivePlayer');
params.player_ch.configPlayerView({
rect: params.player_rect,
fixedOn: params.frame_name,
fixed: true,
enableAEC: true,
});
console.log("播放器准备中: initPlayer and enableHWAcceleration");
params.player_ch.initPlayer();
params.player_ch.enableHWAcceleration({
HWAcceleration: true
});
console.log("播放器准备中: setMute");
params.player_ch.setMute({
enable: false,
});
console.log("播放器准备中: setPlayConfig");
params.player_ch.setPlayConfig({
enableAEC: true,
connectRetryCount: 3,//播放器遭遇网络连接断开时 SDK 默认重试的次数
connectRetryInterval: 3,
cacheTime: 5, // 播放器缓存时间
//bAutoAdjustCacheTime: true,
//maxAutoAdjustCacheTime: 5,
//minAutoAdjustCacheTime: 2,
//videoBlockThreshold: 800, //播放器视频卡顿报警阈值,单位毫秒。只有渲染间隔超过这个阈值的卡顿才会有
});
console.log("播放器准备中: addEventListener");
params.player_ch.addEventListener(
function (ret) {
console.log("播放器回调: " + JSON.stringify(ret));
if (ret.evtID == -2301) {
//console.log(this.frame_name + ':' + '异常,从此不再连接');
// 重新关掉播放器, 再打开播放器
if (this.hasOwnProperty('svr_except')) {
console.log(this.frame_name + ':' + '异常,从此不再连接');
this.svr_except();
}
} else if (ret.evtID == 2103) {
//console.log(this.frame_name + ':' + '远程服务器断开了');
if (this.hasOwnProperty('svr_broken')) {
console.log(this.frame_name + ':' + '远程服务器断开了');
this.svr_broken();
}
} else if (ret.evtID == 2005) {
console.log('playing');
} else if (ret.evtID == 2105) {
console.log('网络不顺畅');
**.**_block(); // 策略: 出现3次这样, 就要报警..
} else if (ret.evtID == 2004) {
console.log('开始播放');
this.play_begin();
}
/*if (ret.evtID == 2026) {
this.setPlayConfig({
enableAEC: true,
});
this.setMute({
enable: true,
});
}*/
}.bind(params)
);
} // end of sw_pb.ch_play_init
|
|