更新接口
This commit is contained in:
parent
590c54b777
commit
25185be6fe
@ -25,16 +25,17 @@ public class LiveDanmuController {
|
|||||||
@ResponseBody
|
@ResponseBody
|
||||||
@RequestMapping("/live/danmu/stop")
|
@RequestMapping("/live/danmu/stop")
|
||||||
public JSONObject stopLiveDanmu(String roomId) {
|
public JSONObject stopLiveDanmu(String roomId) {
|
||||||
service.stop(roomId);
|
service.stop(roomId,true);
|
||||||
return ResultData.success(ReturnCode.RC100);
|
return ResultData.success(ReturnCode.RC100);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@RequestMapping("/live/danmu/start")
|
@RequestMapping("/live/danmu/start")
|
||||||
public JSONObject startLiveDanmu(String roomId) {
|
public JSONObject startLiveDanmu(String roomId) {
|
||||||
service.start(roomId);
|
service.start(roomId, true);
|
||||||
return ResultData.success(ReturnCode.RC100);
|
return ResultData.success(ReturnCode.RC100);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@RequestMapping("/live/danmu/file/list")
|
@RequestMapping("/live/danmu/file/list")
|
||||||
public JSONObject getDanmuList(String roomId) {
|
public JSONObject getDanmuList(String roomId) {
|
||||||
|
@ -21,12 +21,12 @@ import java.util.List;
|
|||||||
@Service
|
@Service
|
||||||
public class LiveDanmuService {
|
public class LiveDanmuService {
|
||||||
|
|
||||||
public void start(String roomId) {
|
public void start(String roomId,boolean isUser) {
|
||||||
WebSocketManager.getInstance().addRoom(LiveRoomConfig.buildConfig(roomId), true);
|
WebSocketManager.getInstance().addRoom(LiveRoomConfig.buildConfig(roomId), isUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stop(String roomId) {
|
public void stop(String roomId,boolean isUser) {
|
||||||
WebSocketManager.getInstance().stopRoom(roomId, true);
|
WebSocketManager.getInstance().stopRoom(roomId, isUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
public JSONArray getLiveRoomList() {
|
public JSONArray getLiveRoomList() {
|
||||||
|
@ -29,6 +29,8 @@ import java.util.concurrent.TimeUnit;
|
|||||||
public class SystemService {
|
public class SystemService {
|
||||||
@Resource
|
@Resource
|
||||||
LiveVideoService videoService;
|
LiveVideoService videoService;
|
||||||
|
@Resource
|
||||||
|
LiveDanmuService danmuService;
|
||||||
SystemConfigDatabases databases = new SystemConfigDatabases();
|
SystemConfigDatabases databases = new SystemConfigDatabases();
|
||||||
private ScheduledExecutorService timer;
|
private ScheduledExecutorService timer;
|
||||||
private ScheduledFuture<?> scheduled;
|
private ScheduledFuture<?> scheduled;
|
||||||
@ -52,7 +54,7 @@ public class SystemService {
|
|||||||
}
|
}
|
||||||
scheduled = timer.scheduleAtFixedRate(() -> {
|
scheduled = timer.scheduleAtFixedRate(() -> {
|
||||||
List<LiveConfigDatabaseBean> list = liveConfigDatabase.getAllConfig();
|
List<LiveConfigDatabaseBean> list = liveConfigDatabase.getAllConfig();
|
||||||
System.out.println("循环任务:"+list.size());
|
System.out.println("循环任务:" + list.size());
|
||||||
for (LiveConfigDatabaseBean bean : list) {
|
for (LiveConfigDatabaseBean bean : list) {
|
||||||
if (bean.isRecordDanmu() && bean.checkRecordDanmuTime()) {
|
if (bean.isRecordDanmu() && bean.checkRecordDanmuTime()) {
|
||||||
recordDanmu(bean);
|
recordDanmu(bean);
|
||||||
@ -63,19 +65,15 @@ public class SystemService {
|
|||||||
}
|
}
|
||||||
}, 0, getLoopTimer(), TimeUnit.MILLISECONDS);
|
}, 0, getLoopTimer(), TimeUnit.MILLISECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stop() {
|
public void stop() {
|
||||||
scheduled.cancel(true);
|
scheduled.cancel(true);
|
||||||
videoService.stopAll();
|
videoService.stopAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 录制弹幕
|
// 录制弹幕
|
||||||
private void recordDanmu(LiveConfigDatabaseBean bean) {
|
private void recordDanmu(LiveConfigDatabaseBean bean) {
|
||||||
LiveRoomConfig config = new LiveRoomConfig();
|
danmuService.start(bean.getRoomId().toString(),false);
|
||||||
config.setLoginUid(bean.getRecordUid());
|
|
||||||
config.setRoomId(bean.getRoomId());
|
|
||||||
config.setAnchorName(bean.getAnchorName());
|
|
||||||
config.setLogin(StringUtils.hasText(bean.getRecordUid()));
|
|
||||||
config.setRootPath(bean.getRecordPath());
|
|
||||||
WebSocketManager.getInstance().addRoom(config,false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 录制视频
|
// 录制视频
|
||||||
|
Loading…
Reference in New Issue
Block a user