Commit f8e3bb70a8c9f58189e5f8db0ddf84586d06befe
1 parent
c06e7402
1.专辑/单集 增加跳过片头片尾逻辑
2.切换清晰度时不处理跳过片头片尾逻辑
Showing
2 changed files
with
96 additions
and
6 deletions
metaCode/Classes/Main/HuBiLieHomePage/Controller/CNLiveTVPlayerViewController.swift
| @@ -29,6 +29,8 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa | @@ -29,6 +29,8 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa | ||
| 29 | 29 | ||
| 30 | //当前选择内容是否需要付费 | 30 | //当前选择内容是否需要付费 |
| 31 | var currentPlayIsNeedPay = false | 31 | var currentPlayIsNeedPay = false |
| 32 | + //是否正在跳过片尾 ,播放下一集 | ||
| 33 | + var isSkipEndPlayNext = false | ||
| 32 | 34 | ||
| 33 | 35 | ||
| 34 | var player: CNLiveZFPlayerController! | 36 | var player: CNLiveZFPlayerController! |
| @@ -601,6 +603,58 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa | @@ -601,6 +603,58 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa | ||
| 601 | } | 603 | } |
| 602 | } | 604 | } |
| 603 | var endAssetURL:URL? | 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 | self.player.playerDidToEnd = { | 659 | self.player.playerDidToEnd = { |
| 606 | [weak self] asset in | 660 | [weak self] asset in |
| @@ -608,7 +662,10 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa | @@ -608,7 +662,10 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa | ||
| 608 | 662 | ||
| 609 | if endAssetURL == nil { | 663 | if endAssetURL == nil { |
| 610 | endAssetURL = asset.assetURL | 664 | endAssetURL = asset.assetURL |
| 611 | - self.playNextIfExist() | 665 | + if !self.isSkipEndPlayNext{ |
| 666 | + self.playNextIfExist() | ||
| 667 | + } | ||
| 668 | + self.isSkipEndPlayNext = true | ||
| 612 | }else{ | 669 | }else{ |
| 613 | //一个视频回调 两次end | 670 | //一个视频回调 两次end |
| 614 | endAssetURL = nil | 671 | endAssetURL = nil |
| @@ -1098,7 +1155,7 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa | @@ -1098,7 +1155,7 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa | ||
| 1098 | self.controlView.gaoqingBgView.resetGaoqing() | 1155 | self.controlView.gaoqingBgView.resetGaoqing() |
| 1099 | } | 1156 | } |
| 1100 | self.controlView.payBgView.isHidden = true | 1157 | self.controlView.payBgView.isHidden = true |
| 1101 | - self.isSeek = false | 1158 | + |
| 1102 | 1159 | ||
| 1103 | self.player.currentPlayerManager.rate = 1.0 | 1160 | self.player.currentPlayerManager.rate = 1.0 |
| 1104 | self.controlView.beiSuBgView.setDefault1Beisu() | 1161 | self.controlView.beiSuBgView.setDefault1Beisu() |
| @@ -1111,9 +1168,37 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa | @@ -1111,9 +1168,37 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa | ||
| 1111 | self.player.assetURLs = urls | 1168 | self.player.assetURLs = urls |
| 1112 | self.player.playTheIndex(0) | 1169 | self.player.playTheIndex(0) |
| 1113 | self.controlView.showTitle(title, cover: UIImage.imageWithColor(color: .darkGray, size: CGSize(width: 50, height: 50)), fullScreenMode: .landscape) | 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 | //上报end | 1199 | //上报end |
| 1116 | CNLiveShortVideoViewModel.requestVodPlayRecordEnd(contentId: self.contentId , channelName: "yszg",model: self.vodPlayModel?.model ?? "1") | 1200 | CNLiveShortVideoViewModel.requestVodPlayRecordEnd(contentId: self.contentId , channelName: "yszg",model: self.vodPlayModel?.model ?? "1") |
| 1201 | + self.isSeek = false | ||
| 1117 | } | 1202 | } |
| 1118 | func seekPlayerWithUrlAndTitle(url:String,title:String,seekTime:TimeInterval){ | 1203 | func seekPlayerWithUrlAndTitle(url:String,title:String,seekTime:TimeInterval){ |
| 1119 | self.isSeek = true | 1204 | self.isSeek = true |
| @@ -1144,7 +1229,7 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa | @@ -1144,7 +1229,7 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa | ||
| 1144 | if status == .success{ | 1229 | if status == .success{ |
| 1145 | if let vodPlayModel = result as? CNLiveVodPlayModel{ | 1230 | if let vodPlayModel = result as? CNLiveVodPlayModel{ |
| 1146 | self.vodPlayModel = vodPlayModel | 1231 | self.vodPlayModel = vodPlayModel |
| 1147 | - self.controlView.vodPlayModel = vodPlayModel | 1232 | + self.controlView.vodPlayModel = self.vodPlayModel |
| 1148 | self.configDataArray() | 1233 | self.configDataArray() |
| 1149 | self.tableView.reloadData() | 1234 | self.tableView.reloadData() |
| 1150 | }else{ | 1235 | }else{ |
| @@ -1301,7 +1386,7 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa | @@ -1301,7 +1386,7 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa | ||
| 1301 | } | 1386 | } |
| 1302 | tempVodPlayModel.goodsJson = vodPlayModel.goodsJson | 1387 | tempVodPlayModel.goodsJson = vodPlayModel.goodsJson |
| 1303 | self.vodPlayModel = tempVodPlayModel | 1388 | self.vodPlayModel = tempVodPlayModel |
| 1304 | - self.controlView.vodPlayModel = tempVodPlayModel | 1389 | + self.controlView.vodPlayModel = self.vodPlayModel |
| 1305 | 1390 | ||
| 1306 | //刷新url 1955_71512cfbcd5b497580732b48e26d16d6 | 1391 | //刷新url 1955_71512cfbcd5b497580732b48e26d16d6 |
| 1307 | if isRefreshPlayer{ | 1392 | if isRefreshPlayer{ |
| @@ -1354,6 +1439,7 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa | @@ -1354,6 +1439,7 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa | ||
| 1354 | 1439 | ||
| 1355 | self.configDataArray() | 1440 | self.configDataArray() |
| 1356 | self.tableView.reloadData() | 1441 | self.tableView.reloadData() |
| 1442 | + self.isSkipEndPlayNext = false | ||
| 1357 | }else{ | 1443 | }else{ |
| 1358 | 1444 | ||
| 1359 | } | 1445 | } |
| @@ -1372,7 +1458,7 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa | @@ -1372,7 +1458,7 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa | ||
| 1372 | hiddenLoading() | 1458 | hiddenLoading() |
| 1373 | if status == .success{ | 1459 | if status == .success{ |
| 1374 | self.vodPlayModel = vodPlayModel | 1460 | self.vodPlayModel = vodPlayModel |
| 1375 | - self.controlView.vodPlayModel = vodPlayModel | 1461 | + self.controlView.vodPlayModel = self.vodPlayModel |
| 1376 | self.contentId = contentId | 1462 | self.contentId = contentId |
| 1377 | if let vodAlbumListBaseModel = result{ | 1463 | if let vodAlbumListBaseModel = result{ |
| 1378 | self.vodAlbumListBaseModel = vodAlbumListBaseModel | 1464 | self.vodAlbumListBaseModel = vodAlbumListBaseModel |
metaCode/Classes/Main/HuBiLieHomePage/Model/CNLiveVodPlayModel.swift
| @@ -19,7 +19,7 @@ class CNLiveVodPlayModel:BaseModel{ | @@ -19,7 +19,7 @@ class CNLiveVodPlayModel:BaseModel{ | ||
| 19 | var goodsJson = "" | 19 | var goodsJson = "" |
| 20 | var goodsName = "" | 20 | var goodsName = "" |
| 21 | var model = "" | 21 | var model = "" |
| 22 | - var duration = "" | 22 | + var duration = ""//总时长s |
| 23 | var attention = false | 23 | var attention = false |
| 24 | var playTime = "" | 24 | var playTime = "" |
| 25 | var product:CNLiveAlbumProductModel? | 25 | var product:CNLiveAlbumProductModel? |
| @@ -27,6 +27,10 @@ class CNLiveVodPlayModel:BaseModel{ | @@ -27,6 +27,10 @@ class CNLiveVodPlayModel:BaseModel{ | ||
| 27 | var sp:CNLiveVodPlaySPModel? | 27 | var sp:CNLiveVodPlaySPModel? |
| 28 | var blockList = [CNLiveVodPlayBlockListModel]() | 28 | var blockList = [CNLiveVodPlayBlockListModel]() |
| 29 | var signIn = false | 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 | var goodShopModelArr = [CNLiveVodPlayShopModel]()//电商goodJson转换的数据 | 36 | var goodShopModelArr = [CNLiveVodPlayShopModel]()//电商goodJson转换的数据 |