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