admin
2021-09-24 f788607ff771a47bc60d6a86e00b3433c40f3d2c
src/main/java/com/yeshi/buwan/service/imp/juhe/FunTV2ServiceImpl.java
@@ -6,25 +6,24 @@
import com.yeshi.buwan.dao.juhe.funtv.FunTVVideo2Dao;
import com.yeshi.buwan.dao.juhe.funtv.VideoFunTV2Dao;
import com.yeshi.buwan.dao.video.AlbumVideoMapDao;
import com.yeshi.buwan.domain.ResourceVideo;
import com.yeshi.buwan.domain.VideoDetailInfo;
import com.yeshi.buwan.domain.VideoInfo;
import com.yeshi.buwan.domain.VideoResource;
import com.yeshi.buwan.domain.entity.PlayUrl;
import com.yeshi.buwan.domain.system.DetailSystemConfig;
import com.yeshi.buwan.domain.video.AlbumVideoMap;
import com.yeshi.buwan.funtv.FunTVUtil2;
import com.yeshi.buwan.funtv.entity.FunTVAlbum2;
import com.yeshi.buwan.funtv.entity.FunTVShortVideo2;
import com.yeshi.buwan.funtv.entity.FunTVVideo2;
import com.yeshi.buwan.funtv.entity.VideoFunTV2;
import com.yeshi.buwan.service.imp.CategoryVideoService;
import com.yeshi.buwan.service.imp.ResourceVideoService;
import com.yeshi.buwan.service.imp.VideoInfoService;
import com.yeshi.buwan.service.imp.VideoResourceService;
import com.yeshi.buwan.videos.funtv.FunTVUtil2;
import com.yeshi.buwan.videos.funtv.entity.FunTVAlbum2;
import com.yeshi.buwan.videos.funtv.entity.FunTVShortVideo2;
import com.yeshi.buwan.videos.funtv.entity.FunTVVideo2;
import com.yeshi.buwan.videos.funtv.entity.VideoFunTV2;
import com.yeshi.buwan.service.imp.*;
import com.yeshi.buwan.service.inter.juhe.FunTV2Service;
import com.yeshi.buwan.util.StringUtil;
import com.yeshi.buwan.util.mq.CMQManager;
import com.yeshi.buwan.util.video.VideoConstant;
import com.yeshi.buwan.vo.AcceptData;
import net.sf.json.JSONObject;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -64,6 +63,9 @@
    @Resource
    private VideoResourceService videoResourceService;
    @Resource
    private DetailSystemConfigService detailSystemConfigService;
    @Override
@@ -217,11 +219,58 @@
            return 1;
    }
    private int getPlayType(AcceptData acceptData, FunTVVideo2 video2) {
        //如果是正在上线的版本就用SDK播放,否则采用H5
        DetailSystemConfig config = detailSystemConfigService.getConfigByKey("funshion_sdk_player", acceptData.getDetailSystem(), acceptData.getVersion());
        //默认SDK播放
        if (config == null)
            return FunTVUtil2.PLAY_SDK;
        String channel = acceptData.getChannel();
        if (StringUtil.isNullOrEmpty(channel)) {
            channel = "qq";
        }
        channel = channel.toLowerCase().trim();
        JSONObject data = JSONObject.fromObject(config.getValue());
        JSONObject channelJSON = data.optJSONObject(channel);
        //渠道不存在就当做QQ渠道做处理
        if (channelJSON == null)
            channelJSON = data.optJSONObject("qq");
        if (channelJSON == null)
            return FunTVUtil2.PLAY_SDK;
        int version = channelJSON.optInt("version");
        if (acceptData.getVersion() < version) {
            //取设定值
            String type = channelJSON.optString("type");
            if ("html".equalsIgnoreCase(type)) {
                return FunTVUtil2.PLAY_HTML;
            } else if ("sdk".equalsIgnoreCase(type)) {
                return FunTVUtil2.PLAY_SDK;
            } else {
                return FunTVUtil2.PLAY_NONE;
            }
        } else {
            //取设定相反值
            String type = channelJSON.optString("type");
            if ("html".equalsIgnoreCase(type)) {
                return FunTVUtil2.PLAY_SDK;
            } else if ("sdk".equalsIgnoreCase(type)) {
                return FunTVUtil2.PLAY_HTML;
            } else {
                return FunTVUtil2.PLAY_NONE;
            }
        }
    }
    @Override
    public PlayUrl getPlayUrl(AcceptData acceptData, String detailSystemId, int resourceId, String id, String videoId) {
        FunTVVideo2 video2 = funTVVideo2Dao.get(id);
        VideoResource vr = videoResourceService.getResource(resourceId + "");
        int t = FunTVUtil2.getPlayType(acceptData,video2);
        int t = getPlayType(acceptData, video2);
        PlayUrl pu = new PlayUrl();
        pu.setParams("");
        pu.setPlayType(t);
@@ -259,7 +308,7 @@
        if (videoFunTV2 == null)
            return;
        videoFunTV2Dao.deleteByVideoId(videoFunTV2.getVideoId());
        resourceVideoService.delete(videoFunTV2.getVideoId()+"",FunTVUtil2.RESOURCE_ID+"");
        resourceVideoService.delete(videoFunTV2.getVideoId() + "", FunTVUtil2.RESOURCE_ID + "");
        //删除媒体与媒体对应的视频
        funTVAlbum2Dao.delete(mediaId);
        List<FunTVVideo2> video2List = listAllEpisodeList(mediaId);