Commit f8e3bb70a8c9f58189e5f8db0ddf84586d06befe

Authored by 张旭
1 parent c06e7402

1.专辑/单集 增加跳过片头片尾逻辑

2.切换清晰度时不处理跳过片头片尾逻辑
metaCode/Classes/Main/HuBiLieHomePage/Controller/CNLiveTVPlayerViewController.swift
... ... @@ -29,6 +29,8 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa
29 29  
30 30 //当前选择内容是否需要付费
31 31 var currentPlayIsNeedPay = false
  32 + //是否正在跳过片尾 ,播放下一集
  33 + var isSkipEndPlayNext = false
32 34  
33 35  
34 36 var player: CNLiveZFPlayerController!
... ... @@ -601,6 +603,58 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa
601 603 }
602 604 }
603 605 var endAssetURL:URL?
  606 + // player更新时间
  607 + self.player.playerPlayTimeChanged = { [weak self] asset, currentTime, duration in
  608 + guard let self = self else { return }
  609 + print("currentTime:\(currentTime),duration:\(duration)")
  610 + //如果跳过片头片尾seek
  611 + if metaAppDelegate.isSkip{
  612 +// let openingDuration = self.vodPlayModel?.openingDuration ?? "0"
  613 +// if let seconds = Double(openingDuration) {
  614 +// let timeInterval: TimeInterval = seconds
  615 +// if timeInterval > 0{
  616 +// DispatchQueue.main.asyncAfter(deadline: .now() + 1.0) {
  617 +// self.player.seek(toTime: timeInterval)
  618 +// }
  619 +// }else{
  620 +// print("片头为0")
  621 +// }
  622 +// print("转换结果: \(timeInterval)") // 输出: 50.0
  623 +// } else {
  624 +// print("无效的秒数字符串")
  625 +// }
  626 + let endingDuration = self.vodPlayModel?.endingDuration ?? "0"
  627 + if let seconds = Double(endingDuration) {
  628 + let timeInterval: TimeInterval = seconds
  629 + if timeInterval > 0 && currentTime+timeInterval>duration{
  630 + if !self.isSkipEndPlayNext{
  631 + DispatchQueue.main.asyncAfter(deadline: .now() + 1.0) {
  632 + self.playNextIfExist()
  633 + //上报end
  634 + CNLiveShortVideoViewModel.requestVodPlayRecordEnd(contentId: self.contentId , channelName: "yszg",model: self.vodPlayModel?.model ?? "1")
  635 + print("\(self.contentId),\(self.vodPlayModel?.model)")
  636 +
  637 + //刷新选集-专辑列表
  638 + if self.isPlayAblumOrKandian{
  639 + self.controlView.xuanjiBgView.currSeleIdx = self.albumIndex
  640 + }else{
  641 + //刷新选集-看点列表
  642 + self.controlView.xuanjiBgView.currSeleIdx = self.kanDianIndex
  643 + self.controlView.xuanjiBgView.kandianTableView.reloadData()
  644 + }
  645 + }
  646 + }
  647 + self.isSkipEndPlayNext = true
  648 + }else{
  649 + print("片头为0")
  650 + }
  651 + } else {
  652 + print("无效的秒数字符串")
  653 + }
  654 + }else{
  655 +
  656 + }
  657 + }
604 658 /// 播放完成
605 659 self.player.playerDidToEnd = {
606 660 [weak self] asset in
... ... @@ -608,7 +662,10 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa
608 662  
609 663 if endAssetURL == nil {
610 664 endAssetURL = asset.assetURL
611   - self.playNextIfExist()
  665 + if !self.isSkipEndPlayNext{
  666 + self.playNextIfExist()
  667 + }
  668 + self.isSkipEndPlayNext = true
612 669 }else{
613 670 //一个视频回调 两次end
614 671 endAssetURL = nil
... ... @@ -1098,7 +1155,7 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa
1098 1155 self.controlView.gaoqingBgView.resetGaoqing()
1099 1156 }
1100 1157 self.controlView.payBgView.isHidden = true
1101   - self.isSeek = false
  1158 +
1102 1159  
1103 1160 self.player.currentPlayerManager.rate = 1.0
1104 1161 self.controlView.beiSuBgView.setDefault1Beisu()
... ... @@ -1111,9 +1168,37 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa
1111 1168 self.player.assetURLs = urls
1112 1169 self.player.playTheIndex(0)
1113 1170 self.controlView.showTitle(title, cover: UIImage.imageWithColor(color: .darkGray, size: CGSize(width: 50, height: 50)), fullScreenMode: .landscape)
  1171 +
  1172 + //如果跳过片头片尾 ,且没有切换清晰度seek
  1173 + if metaAppDelegate.isSkip && !self.isSeek{
  1174 + let openingDuration = self.vodPlayModel?.openingDuration ?? "0"
  1175 + let endingDuration = self.vodPlayModel?.endingDuration ?? "0"
  1176 + if let seconds = Double(openingDuration) {
  1177 + let timeInterval: TimeInterval = seconds
  1178 + if timeInterval > 0{
  1179 + DispatchQueue.main.asyncAfter(deadline: .now() + 1.0) {
  1180 + self.player.seek(toTime: timeInterval)
  1181 + }
  1182 + }else{
  1183 + print("片头为0")
  1184 + }
  1185 + print("转换结果: \(timeInterval)") // 输出: 50.0
  1186 + } else {
  1187 + print("无效的秒数字符串")
  1188 + }
  1189 + if let seconds = Double(endingDuration) {
  1190 + let timeInterval: TimeInterval = seconds
  1191 + print("转换结果: \(timeInterval)") // 输出: 50.0
  1192 + } else {
  1193 + print("无效的秒数字符串")
  1194 + }
  1195 + }else{
  1196 +
  1197 + }
1114 1198 }
1115 1199 //上报end
1116 1200 CNLiveShortVideoViewModel.requestVodPlayRecordEnd(contentId: self.contentId , channelName: "yszg",model: self.vodPlayModel?.model ?? "1")
  1201 + self.isSeek = false
1117 1202 }
1118 1203 func seekPlayerWithUrlAndTitle(url:String,title:String,seekTime:TimeInterval){
1119 1204 self.isSeek = true
... ... @@ -1144,7 +1229,7 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa
1144 1229 if status == .success{
1145 1230 if let vodPlayModel = result as? CNLiveVodPlayModel{
1146 1231 self.vodPlayModel = vodPlayModel
1147   - self.controlView.vodPlayModel = vodPlayModel
  1232 + self.controlView.vodPlayModel = self.vodPlayModel
1148 1233 self.configDataArray()
1149 1234 self.tableView.reloadData()
1150 1235 }else{
... ... @@ -1301,7 +1386,7 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa
1301 1386 }
1302 1387 tempVodPlayModel.goodsJson = vodPlayModel.goodsJson
1303 1388 self.vodPlayModel = tempVodPlayModel
1304   - self.controlView.vodPlayModel = tempVodPlayModel
  1389 + self.controlView.vodPlayModel = self.vodPlayModel
1305 1390  
1306 1391 //刷新url 1955_71512cfbcd5b497580732b48e26d16d6
1307 1392 if isRefreshPlayer{
... ... @@ -1354,6 +1439,7 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa
1354 1439  
1355 1440 self.configDataArray()
1356 1441 self.tableView.reloadData()
  1442 + self.isSkipEndPlayNext = false
1357 1443 }else{
1358 1444  
1359 1445 }
... ... @@ -1372,7 +1458,7 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa
1372 1458 hiddenLoading()
1373 1459 if status == .success{
1374 1460 self.vodPlayModel = vodPlayModel
1375   - self.controlView.vodPlayModel = vodPlayModel
  1461 + self.controlView.vodPlayModel = self.vodPlayModel
1376 1462 self.contentId = contentId
1377 1463 if let vodAlbumListBaseModel = result{
1378 1464 self.vodAlbumListBaseModel = vodAlbumListBaseModel
... ...
metaCode/Classes/Main/HuBiLieHomePage/Model/CNLiveVodPlayModel.swift
... ... @@ -19,7 +19,7 @@ class CNLiveVodPlayModel:BaseModel{
19 19 var goodsJson = ""
20 20 var goodsName = ""
21 21 var model = ""
22   - var duration = ""
  22 + var duration = ""//总时长s
23 23 var attention = false
24 24 var playTime = ""
25 25 var product:CNLiveAlbumProductModel?
... ... @@ -27,6 +27,10 @@ class CNLiveVodPlayModel:BaseModel{
27 27 var sp:CNLiveVodPlaySPModel?
28 28 var blockList = [CNLiveVodPlayBlockListModel]()
29 29 var signIn = false
  30 + var openingDuration = "0"//片头时长s
  31 + var endingDuration = "0"//片尾时长s
  32 + var openingDurationTime:Double = 0.0//片头时长s
  33 + var endingDurationTime:Double = 0.0//片尾时长s
30 34  
31 35 //非接口数据
32 36 var goodShopModelArr = [CNLiveVodPlayShopModel]()//电商goodJson转换的数据
... ...