修复结束直播隐藏问题

This commit is contained in:
easonzhu 2025-04-03 11:10:19 +08:00
parent 601d339055
commit 67ffe48eee
2 changed files with 16 additions and 5 deletions

View File

@ -535,7 +535,7 @@ public class AdminVideoInfoService {
if (isSoldOut) {
//下架修改直播状态和推流状态
video.setLiveStatus(VideoLiveStatus.HAS_ENDED.value);
videoCommonService.endVideo(null, new VideoLive(id, VideoLiveStatus.HAS_ENDED.value, now));
videoCommonService.endVideo(null, new VideoLive(id, VideoLiveStatus.HAS_ENDED.value, now), false);
}
if (VideoLiveStatus.LIVING.value.equals(videoInDb.getLiveStatus())) {
video.setRealEndTime(now);

View File

@ -1,6 +1,7 @@
package com.syzb.video.service.common;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.exceptions.ExceptionUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@ -215,7 +216,7 @@ public class VideoCommonService {
Integer totalReadCount = adminVideoInteractionService.queryInteractionCount(v.getId(), VideoUserRecordType.READ, null, null, false);
entity.setLiveNum(totalReadCount);
videoLiveMapper.updateById(entity);
endVideo(cacheMap, v);
endVideo(cacheMap, v, true);
adminVideoQuestionService.stopByVideoId(v.getId());
});
}
@ -248,11 +249,21 @@ public class VideoCommonService {
* @param cacheMap 缓存
* @param video 直播信息
*/
public void endVideo(Map<String, Object> cacheMap, VideoLive video) {
public void endVideo(Map<String, Object> cacheMap, VideoLive video, boolean isTask) {
// 清除直播状态缓存
videoCacheService.clearVideoInfoCache(video.getId(), cacheMap);
// 已结束中断投顾推流
videoCloudService.dropLiveStream(video.getId());
// 已结束禁推投顾推流
try {
if (isTask) {
videoCloudService.stopRecordTask(video);
videoCloudService.forbidLiveStream(video.getId().toString());
} else {
videoCloudService.dropLiveStream(video.getId());
}
} catch(Exception e) {
// 忽略异常
LoggerUtil.error("结束直播失败:", ExceptionUtil.stacktraceToString(e));
}
// 直播结束通知
videoMessageService.publishLiveStatusNotification(video.getId(), VideoLiveStatus.HAS_ENDED.value);
// 直播状态推送(pc)