新增直播定时器,每秒检测下直播状态及录像状态
This commit is contained in:
parent
b078e5f9b5
commit
ef0d7e5850
@ -46,6 +46,7 @@ public class Live implements ApplicationContextAware {
|
||||
private BilibiliUpInfo upData;
|
||||
private Timer heartBeattimer;
|
||||
public BiliBiliLiveDatabasesManager danmuManager = null;
|
||||
public Timer checkLiveTimer;
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
@ -80,6 +81,13 @@ public class Live implements ApplicationContextAware {
|
||||
Live.lives.add(this);
|
||||
updateUpInfo();
|
||||
com.yutou.bilibili.Tools.Log.i("roomId = " + roomId + ", isLogin = " + isLogin);
|
||||
checkLiveTimer=new Timer();
|
||||
checkLiveTimer.schedule(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
checkLive();
|
||||
}
|
||||
},0,1000);
|
||||
}
|
||||
|
||||
private void updateUpInfo() {
|
||||
@ -208,6 +216,9 @@ public class Live implements ApplicationContextAware {
|
||||
}
|
||||
Live.lives.remove(this);
|
||||
com.yutou.bilibili.Tools.Log.i("退出" + roomId + "直播间");
|
||||
if(checkLiveTimer!=null){
|
||||
checkLiveTimer.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -272,9 +283,9 @@ public class Live implements ApplicationContextAware {
|
||||
} catch (Exception e) {
|
||||
int popular = LiveUtils.bytesToInt2(bytes, 0);
|
||||
info.setPopular(popular);
|
||||
}
|
||||
}
|
||||
checkLive();
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
com.yutou.bilibili.Tools.Log.i("----------ERROR----------");
|
||||
@ -290,7 +301,7 @@ public class Live implements ApplicationContextAware {
|
||||
if (isLive && upData.getSavelive() == 1) {
|
||||
SaveLive.getInstance().addLive(this);
|
||||
}
|
||||
if(!isLive&&upData.getSavelive()==1){
|
||||
if (!isLive || upData.getSavelive() == 0) {
|
||||
if (SaveLive.getInstance().checkLive(roomId)) {
|
||||
SaveLive.getInstance().stop(roomId);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user