CNLivePlayerTool.swift 3.09 KB
//
//  CNLivePlayerTool.swift
//  metaCode
//
//  Created by zx on 2025/2/25.
//  vid获取播放地址url

import Foundation

class CNLivePlayerTool:NSObject{
    
    //判断 专辑/单集 是否需要付费
    class func isPaid(product:CNLiveAlbumProductModel?) -> Bool{
        var isPaid:Bool = false
        if product?.check == true{
            //付过费/免费
            isPaid = false
        }else{
            if product?.albumProductType.count ?? 0 > 0{
                //专辑
                if product?.albumProductType == "2" || product?.albumProductType == "5"{
                    //人民币 ,专辑付费
                    isPaid = true
                }else{
                    //免费
                }
            }else{
                //单集
                if product?.productType.count ?? 0 > 0{
                    //单集
                    if product?.productType == "2" || product?.productType == "5"{
                        //人民币付费 / 专辑付费
                        isPaid = true
                    }else{
                        //免费
                    }
                }else{
                    //免费
                }
            }
        }
        return isPaid
    }

    //判断 专辑/单集 是否需要展示付费icon角标
    class func isShowPaidIcon(product:CNLiveAlbumProductModel?) -> Bool{
        var isPaid:Bool = false
        if product?.albumProductType.count ?? 0 > 0{
            //专辑
            if product?.albumProductType == "2" || product?.albumProductType == "5"{
                //人民币 ,专辑付费
                isPaid = true
            }else{
                //免费
            }
        }else{
            //单集
            if product?.productType.count ?? 0 > 0{
                //单集
                if product?.productType == "2" || product?.productType == "5"{
                    //人民币付费 / 专辑付费
                    isPaid = true
                }else{
                    //免费
                }
            }else{
                //免费
            }
        }
        return isPaid
    }
    
    class func vidGetPlayerUrl(contentId:String){
        
    }
    
    class func pushShortVideoController(contentId:String,navigationVC:UINavigationController?,slideModel:CNLiveDownSlideModel?){
        //请求getAlbumMsg获取上次播放集数
        //获取专辑详情(简介等)
        CNLiveHomePageViewModel.getAlbumMsg(aid: contentId) { result, status in
            hiddenLoading()
            if status == .success{
                let model = result as! CNLiveAlbumMsgModel
                //短剧-跳转短剧播放页
                let toIndex = model.episodeLast-1 <= 0 ? 0 : model.episodeLast-1
                navigationVC?.pushViewController( CNLiveShortVideoViewController(aid: contentId, currentIndex: toIndex, slideModel: slideModel), animated: pushAnimated)
            }else{
                //短剧-跳转短剧播放页
                navigationVC?.pushViewController(CNLiveShortVideoViewController(aid: contentId), animated: pushAnimated)
            }
        }
    }
    
}