Commit 77b5b7a95565ba33f13a559b0d272b12ae677c55

Authored by “张旭”
1 parent e1763f45

高清 清晰度

metaCode.xcodeproj/project.pbxproj
... ... @@ -197,6 +197,8 @@
197 197 1969E1AD2C92E98700E4185E /* CNHomeWebViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1969E1AC2C92E98700E4185E /* CNHomeWebViewController.swift */; };
198 198 1969E1AF2C942F4400E4185E /* CNLivePhotoManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1969E1AE2C942F4400E4185E /* CNLivePhotoManager.swift */; };
199 199 196A55F52D95432B00B06DB7 /* CNLiveVodLandscapeBeiSuView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 196A55F42D95432B00B06DB7 /* CNLiveVodLandscapeBeiSuView.swift */; };
  200 + 196A55F72D963ACE00B06DB7 /* CNLiveVodLandscapeXuanjiView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 196A55F62D963ACE00B06DB7 /* CNLiveVodLandscapeXuanjiView.swift */; };
  201 + 196A55F92D963AE700B06DB7 /* CNLiveVodLandscapeGaoqingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 196A55F82D963AE600B06DB7 /* CNLiveVodLandscapeGaoqingView.swift */; };
200 202 197325D22BB11C18002E41A3 /* DatabaseManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 197325D12BB11C18002E41A3 /* DatabaseManager.swift */; };
201 203 1975636E2C5A2EB2004E0F42 /* CNLiveVitaeWorkDetailController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1975636D2C5A2EB2004E0F42 /* CNLiveVitaeWorkDetailController.swift */; };
202 204 197563712C5A3151004E0F42 /* CNLiveVitaeWorkCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 197563702C5A3151004E0F42 /* CNLiveVitaeWorkCell.swift */; };
... ... @@ -597,6 +599,8 @@
597 599 1969E1AC2C92E98700E4185E /* CNHomeWebViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNHomeWebViewController.swift; sourceTree = "<group>"; };
598 600 1969E1AE2C942F4400E4185E /* CNLivePhotoManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLivePhotoManager.swift; sourceTree = "<group>"; };
599 601 196A55F42D95432B00B06DB7 /* CNLiveVodLandscapeBeiSuView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveVodLandscapeBeiSuView.swift; sourceTree = "<group>"; };
  602 + 196A55F62D963ACE00B06DB7 /* CNLiveVodLandscapeXuanjiView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveVodLandscapeXuanjiView.swift; sourceTree = "<group>"; };
  603 + 196A55F82D963AE600B06DB7 /* CNLiveVodLandscapeGaoqingView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveVodLandscapeGaoqingView.swift; sourceTree = "<group>"; };
600 604 197325D12BB11C18002E41A3 /* DatabaseManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DatabaseManager.swift; sourceTree = "<group>"; };
601 605 1975636D2C5A2EB2004E0F42 /* CNLiveVitaeWorkDetailController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveVitaeWorkDetailController.swift; sourceTree = "<group>"; };
602 606 197563702C5A3151004E0F42 /* CNLiveVitaeWorkCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CNLiveVitaeWorkCell.swift; sourceTree = "<group>"; };
... ... @@ -1484,6 +1488,8 @@
1484 1488 isa = PBXGroup;
1485 1489 children = (
1486 1490 196A55F42D95432B00B06DB7 /* CNLiveVodLandscapeBeiSuView.swift */,
  1491 + 196A55F82D963AE600B06DB7 /* CNLiveVodLandscapeGaoqingView.swift */,
  1492 + 196A55F62D963ACE00B06DB7 /* CNLiveVodLandscapeXuanjiView.swift */,
1487 1493 );
1488 1494 path = HengPing;
1489 1495 sourceTree = "<group>";
... ... @@ -2470,6 +2476,7 @@
2470 2476 19BB1FEA2AEF7B4A0094D962 /* CNLiveShopConsoleCell.swift in Sources */,
2471 2477 191733132B109F7B007BCC04 /* CNLivePlayerGestureView.swift in Sources */,
2472 2478 1938BD202B46799A00390A34 /* CNLivePlayletHomePageController.swift in Sources */,
  2479 + 196A55F72D963ACE00B06DB7 /* CNLiveVodLandscapeXuanjiView.swift in Sources */,
2473 2480 790D019D2A2DCBD000C5978D /* UIView+CNLiveExtensions.swift in Sources */,
2474 2481 790B1FB62A41938F0074CF00 /* UIImage+CNLiveExtensions.swift in Sources */,
2475 2482 196211E52D66F5E6001925EC /* CNLiveHomeADCell.swift in Sources */,
... ... @@ -2574,6 +2581,7 @@
2574 2581 1958B41C2D87BD3E00F37E35 /* CNLiveMinePlayHistoryCollectionCell.swift in Sources */,
2575 2582 19BB1FE62AEB93B80094D962 /* CNLiveShopUserInfoModel.swift in Sources */,
2576 2583 19023DBB2D8270DA00872398 /* CNLiveHomeShopCategoryCell.swift in Sources */,
  2584 + 196A55F92D963AE700B06DB7 /* CNLiveVodLandscapeGaoqingView.swift in Sources */,
2577 2585 1909DCAB2C649C10001E7986 /* CNLiveDigitalResumePreViewSecCollectionCell.swift in Sources */,
2578 2586 195650C32D7543A500818FC8 /* CNLiveVodIntroductionCell.swift in Sources */,
2579 2587 195650BD2D7298E800818FC8 /* CNLiveVodAlbumMsgModel.swift in Sources */,
... ...
metaCode/Classes/Main/HomePages/ViewModel/CNLiveHomePageViewModel.swift
... ... @@ -13,7 +13,11 @@ class CNLiveHomePageViewModel:NSObject,URLSessionTaskDelegate{
13 13  
14 14 ///id获取播放地址url
15 15 func getVodVideoURL(contentId:String,resultBlock: @escaping downSlideResultBlock){
16   -
  16 + self.getVodVideoURL(contentId: contentId, rate: 2, resultBlock: resultBlock)
  17 + }
  18 + ///id获取播放地址url, rate
  19 + func getVodVideoURL(contentId:String,rate:Int,resultBlock: @escaping downSlideResultBlock){
  20 +
17 21 // 获取当前时间戳(自1970年以来的秒数)
18 22 let timeInterval = Date().timeIntervalSince1970
19 23 // 将时间戳转换为字符串
... ... @@ -49,7 +53,7 @@ class CNLiveHomePageViewModel:NSObject,URLSessionTaskDelegate{
49 53 param.setValue(UserInfoManager.shared.userInfo.uid, forKey: "uid")
50 54 param.setValue(UserInfoManager.shared.userInfo.uid, forKey: "loginSid")
51 55 param.setValue("release", forKey: "app_channel_id")
52   - param.setValue("2", forKey: "rate")
  56 + param.setValue("\(rate)", forKey: "rate")
53 57 param.setValue("release", forKey: "app_channel_id")
54 58 param.setValue("0", forKey: "retry")
55 59  
... ... @@ -81,6 +85,7 @@ class CNLiveHomePageViewModel:NSObject,URLSessionTaskDelegate{
81 85  
82 86 task.resume()
83 87 }
  88 +
84 89  
85 90 func urlSession(_ session: URLSession, task: URLSessionTask, willPerformHTTPRedirection response: HTTPURLResponse, newRequest request: URLRequest, completionHandler: @escaping (URLRequest?) -> Void) {
86 91 print("\(response.statusCode)") // 302
... ...
metaCode/Classes/Main/HuBiLieHomePage/Controller/CNLiveTVPlayerViewController.swift
... ... @@ -15,6 +15,8 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa
15 15  
16 16 //当前内容id
17 17 var contentId = ""
  18 + var playTitle = ""
  19 + var isSeek = false
18 20  
19 21 //CNLiveVodPlayModel 单集model
20 22 var _vodPlayModel : CNLiveVodPlayModel?
... ... @@ -280,6 +282,7 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa
280 282 // [self.player stop];
281 283 // }
282 284 }
  285 +
283 286 var urls = [URL]()
284 287 urls.append(self.url!)
285 288 self.player.assetURLs = urls
... ... @@ -296,7 +299,19 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa
296 299 }
297 300 }
298 301 self.controlView.showTitle(title, cover: UIImage.imageWithColor(color: .darkGray, size: CGSize(width: 50, height: 50)), fullScreenMode: .landscape)
299   -
  302 + self.playTitle = title
  303 + self.controlView.controlGaoqingUpdateBlock = { [weak self] gaoqing in
  304 + guard let self = self else { return }
  305 + //
  306 +
  307 + CNLiveHomePageViewModel.shared.getVodVideoURL(contentId: self.vodPlayModel?.contentId ?? "", rate: gaoqing) { result, status in
  308 + if status == .success{
  309 + if let url = result as? String{
  310 + self.seekPlayerWithUrlAndTitle(url: url, title: self.playTitle, seekTime: self.player.currentTime)
  311 + }
  312 + }
  313 + }
  314 + }
300 315 }
301 316  
302 317 // MARK: - UITableViewDelegate
... ... @@ -492,7 +507,13 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa
492 507  
493 508 //播放url更换title
494 509 func playWithUrlAndTitle(url:String,title:String){
  510 + if self.isSeek{
  511 + }else{
  512 + self.controlView.gaoqingBgView.resetGaoqing()
  513 + }
  514 + self.isSeek = false
495 515 self.player.currentPlayerManager.rate = 1.0
  516 + self.playTitle = title
496 517 self.url = URL(string: url)
497 518 var urls = [URL]()
498 519 urls.append(self.url!)
... ... @@ -500,6 +521,12 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa
500 521 self.player.playTheIndex(0)
501 522 self.controlView.showTitle(title, cover: UIImage.imageWithColor(color: .darkGray, size: CGSize(width: 50, height: 50)), fullScreenMode: .landscape)
502 523 }
  524 + func seekPlayerWithUrlAndTitle(url:String,title:String,seekTime:TimeInterval){
  525 + self.isSeek = true
  526 + self.playWithUrlAndTitle(url: url, title: title)
  527 + self.player.seek(toTime: seekTime)
  528 +
  529 + }
503 530  
504 531 override var preferredStatusBarStyle: UIStatusBarStyle{
505 532 return .lightContent
... ...
metaCode/Classes/Main/HuBiLieHomePage/View/VodDetail/CNLiveZFPlayerControlView.swift
... ... @@ -7,8 +7,13 @@
7 7  
8 8 import Foundation
9 9 import ZFPlayer
  10 +
  11 +//标清 2 ,高清 3 ,超清 4
  12 +typealias CNLiveVodPlayerControlLandscapeGaoqingUpdateBlock = (_ gaoqing:Int)->Void
  13 +
10 14 class CNLiveZFPlayerControlView:ZFPlayerControlView{
11 15  
  16 + var controlGaoqingUpdateBlock:CNLiveVodPlayerControlLandscapeGaoqingUpdateBlock?
12 17 lazy var beiSuBtn: UIButton = {
13 18 let closeBtn = UIButton(type: .custom)
14 19 closeBtn.setTitle("倍速", for: .normal)
... ... @@ -42,7 +47,10 @@ class CNLiveZFPlayerControlView:ZFPlayerControlView{
42 47 let bottomNavView = CNLiveVodLandscapeBeiSuView()
43 48 return bottomNavView
44 49 }()
45   -
  50 + lazy var gaoqingBgView :CNLiveVodLandscapeGaoqingView = {
  51 + let bottomNavView = CNLiveVodLandscapeGaoqingView()
  52 + return bottomNavView
  53 + }()
46 54  
47 55 override init(frame: CGRect) {
48 56 super.init(frame: frame)
... ... @@ -88,6 +96,17 @@ class CNLiveZFPlayerControlView:ZFPlayerControlView{
88 96 self.player?.currentPlayerManager.rate = rate
89 97 self.beiSuBgView.isHidden = true
90 98 }
  99 +
  100 + self.addSubview(self.gaoqingBgView)
  101 + gaoqingBgView.snp.makeConstraints { make in
  102 + make.left.right.top.bottom.equalToSuperview()
  103 + }
  104 + self.gaoqingBgView.isHidden = true
  105 + self.gaoqingBgView.gaoqingUpdateBlock = {[weak self] gaoqing in
  106 + guard let self = self else { return }
  107 + self.gaoqingBgView.isHidden = true
  108 + self.controlGaoqingUpdateBlock?(gaoqing)
  109 + }
91 110 }
92 111  
93 112 override func layoutSubviews() {
... ... @@ -116,11 +135,10 @@ class CNLiveZFPlayerControlView:ZFPlayerControlView{
116 135  
117 136 @objc func beiSuBtnAction(){
118 137 self.beiSuBgView.isHidden = false
119   -
120 138 }
121 139  
122 140 @objc func gaoqingBtnAction(){
123   - print("gaoqing")
  141 + self.gaoqingBgView.isHidden = false
124 142 }
125 143  
126 144 @objc func xuanjiBtnAction(){
... ...
metaCode/Classes/Main/HuBiLieHomePage/View/VodDetail/HengPing/CNLiveVodLandscapeGaoqingView.swift 0 → 100644
  1 +//
  2 +// CNLiveVodLandscapeGaoqingView.swift
  3 +// metaCode
  4 +//
  5 +// Created by zx on 2025/3/28.
  6 +// 横屏高清
  7 +
  8 +import Foundation
  9 +
  10 +//标清 2 ,高清 3 ,超清 4
  11 +typealias CNLiveVodLandscapeGaoqingUpdateBlock = (_ gaoqing:Int)->Void
  12 +
  13 +class CNLiveVodLandscapeGaoqingView:UIView{
  14 +
  15 + var gaoqingUpdateBlock:CNLiveVodLandscapeGaoqingUpdateBlock?
  16 + var currSeleIdx = 1//720
  17 + //MARK: - 懒加载
  18 + lazy var titleLabel: UILabel = {
  19 + let titleLbl = UILabel()
  20 + titleLbl.font = Font_14
  21 + titleLbl.textColor = HexColor("#FFFFFF")
  22 + titleLbl.text = "画质"
  23 + return titleLbl
  24 + }()
  25 +
  26 + override init(frame: CGRect) {
  27 + super.init(frame: frame)
  28 + self.backgroundColor = HexColor("#000000", alpha: 0.7)
  29 + self.isUserInteractionEnabled = true
  30 + self.initUI()
  31 + self.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(tapAction)))
  32 + }
  33 +
  34 + required init?(coder: NSCoder) {
  35 + fatalError("init(coder:) has not been implemented")
  36 + }
  37 +
  38 + func initUI(){
  39 +
  40 + self.addSubview(self.titleLabel)
  41 + titleLabel.snp.makeConstraints { make in
  42 + make.top.equalToSuperview().offset(31)
  43 + make.centerX.equalToSuperview()
  44 + }
  45 +
  46 + var WH:CGFloat = 90.0
  47 + let padding:CGFloat = 20.0
  48 + let count:Int = 3
  49 + let leftPadding:CGFloat = (KSreenHeight-WH*CGFloat(count)-padding*CGFloat(count-1))*0.5
  50 + var title = "高清"
  51 + var subTitle = "720P"
  52 +
  53 + for i in 0..<count{
  54 + let expandBtn = UIButton.init(type: .custom)
  55 + expandBtn.frame = CGRect(x: leftPadding+CGFloat(i)*(WH+padding), y: 0, width: WH, height: WH)
  56 + expandBtn.centerY = KSreenWidth*0.5
  57 + if i == 0{
  58 + //标清480
  59 + title = "标清"
  60 + subTitle = "480P"
  61 + }else if i == 1{
  62 + //高清720
  63 + title = "高清"
  64 + subTitle = "720P"
  65 + }else if i == 2{
  66 + //超清1080
  67 + title = "超清"
  68 + subTitle = "1080P"
  69 + }
  70 + expandBtn.setTitle("", for: .normal)
  71 + expandBtn.setTitle("", for: .selected)
  72 + expandBtn.setTitleColor(HexColor("#FFFFFF"), for: .normal)
  73 + expandBtn.setTitleColor(HexColor("#478BFF"), for: .selected)
  74 + expandBtn.titleLabel?.font = Font_18
  75 + expandBtn.layer.cornerRadius = 12
  76 + expandBtn.clipsToBounds = true
  77 + expandBtn.tag = 100+i
  78 + expandBtn.addTarget(self, action: #selector(gaoqingBtnAction), for: .touchUpInside)
  79 + self.addSubview(expandBtn)
  80 +
  81 + let titleLbl = UILabel()
  82 + titleLbl.font = Font_14
  83 + titleLbl.text = title
  84 + expandBtn.addSubview(titleLbl)
  85 + titleLbl.snp.makeConstraints { make in
  86 + make.centerX.equalToSuperview().offset(10)
  87 + make.top.equalToSuperview().offset(30)
  88 + }
  89 +
  90 + let subTitleLbl = UILabel()
  91 + subTitleLbl.font = Font_10
  92 + subTitleLbl.text = subTitle
  93 + expandBtn.addSubview(subTitleLbl)
  94 + subTitleLbl.snp.makeConstraints { make in
  95 + make.centerX.equalToSuperview().offset(10)
  96 + make.top.equalTo(titleLbl.snp.bottom).offset(3)
  97 + }
  98 +
  99 + if i == self.currSeleIdx{
  100 + expandBtn.backgroundColor = HexColor("#D3E4FF")
  101 + expandBtn.layer.borderWidth = 0.65
  102 + expandBtn.layer.borderColor = HexColor("#478BFF")?.cgColor
  103 + expandBtn.isSelected = true
  104 + titleLbl.textColor = HexColor("#0668E7")
  105 + subTitleLbl.textColor = HexColor("#0668E7")
  106 + }else{
  107 + expandBtn.backgroundColor = HexColor("#000000")
  108 + expandBtn.layer.borderWidth = 0
  109 + expandBtn.layer.borderColor = HexColor("#000000")?.cgColor
  110 + expandBtn.isSelected = false
  111 + titleLbl.textColor = HexColor("#FFFFFF")
  112 + subTitleLbl.textColor = HexColor("#FFFFFF")
  113 + }
  114 +
  115 + }
  116 + }
  117 + func resetGaoqing(){
  118 + let btnTag:Int = 101
  119 + for obj in self.subviews{
  120 + if obj.tag >= 100{
  121 + if obj.tag == btnTag{
  122 + if let tmpBtn = obj as? UIButton{
  123 + tmpBtn.backgroundColor = HexColor("#D3E4FF")
  124 + tmpBtn.layer.borderWidth = 0.65
  125 + tmpBtn.layer.borderColor = HexColor("#478BFF")?.cgColor
  126 + tmpBtn.isSelected = true
  127 + for lbl in tmpBtn.subviews{
  128 + if let tmpLbl = lbl as? UILabel{
  129 + tmpLbl.textColor = HexColor("#0668E7")
  130 + }
  131 + }
  132 + }
  133 + }else{
  134 + if let tmpBtn = obj as? UIButton{
  135 + tmpBtn.backgroundColor = HexColor("#000000")
  136 + tmpBtn.layer.borderWidth = 0
  137 + tmpBtn.layer.borderColor = HexColor("#000000")?.cgColor
  138 + tmpBtn.isSelected = false
  139 + for lbl in tmpBtn.subviews{
  140 + if let tmpLbl = lbl as? UILabel{
  141 + tmpLbl.textColor = HexColor("#FFFFFF")
  142 + }
  143 + }
  144 + }
  145 + }
  146 + }
  147 + }
  148 +
  149 + }
  150 + @objc func gaoqingBtnAction(btn:UIButton){
  151 + let btnTag = btn.tag
  152 + for obj in self.subviews{
  153 + if obj.tag >= 100{
  154 + if obj.tag == btnTag{
  155 + if let tmpBtn = obj as? UIButton{
  156 + tmpBtn.backgroundColor = HexColor("#D3E4FF")
  157 + tmpBtn.layer.borderWidth = 0.65
  158 + tmpBtn.layer.borderColor = HexColor("#478BFF")?.cgColor
  159 + tmpBtn.isSelected = true
  160 + for lbl in tmpBtn.subviews{
  161 + if let tmpLbl = lbl as? UILabel{
  162 + tmpLbl.textColor = HexColor("#0668E7")
  163 + }
  164 + }
  165 + }
  166 + }else{
  167 + if let tmpBtn = obj as? UIButton{
  168 + tmpBtn.backgroundColor = HexColor("#000000")
  169 + tmpBtn.layer.borderWidth = 0
  170 + tmpBtn.layer.borderColor = HexColor("#000000")?.cgColor
  171 + tmpBtn.isSelected = false
  172 + for lbl in tmpBtn.subviews{
  173 + if let tmpLbl = lbl as? UILabel{
  174 + tmpLbl.textColor = HexColor("#FFFFFF")
  175 + }
  176 + }
  177 + }
  178 + }
  179 + }
  180 + }
  181 +
  182 + let i = btn.tag-100
  183 + var gaoqing:Int = 3
  184 + if i == 0{
  185 + gaoqing = 2
  186 + }else if i == 1{
  187 + gaoqing = 3
  188 + }else if i == 2{
  189 + gaoqing = 4
  190 + }
  191 + self.gaoqingUpdateBlock?(gaoqing)
  192 + }
  193 +
  194 + @objc func tapAction(){
  195 + self.isHidden = true
  196 + }
  197 +
  198 +}
  199 +
... ...
metaCode/Classes/Main/HuBiLieHomePage/View/VodDetail/HengPing/CNLiveVodLandscapeXuanjiView.swift 0 → 100644
  1 +//
  2 +// CNLiveVodLandscapeXuanjiView.swift
  3 +// metaCode
  4 +//
  5 +// Created by zx on 2025/3/28.
  6 +//
  7 +
  8 +import Foundation
... ...