Commit 580161d340b56a2e7cb679b58ff626be720a25e8
1 parent
16699f9c
播放视频上报 , 支付弹窗逻辑
Showing
5 changed files
with
72 additions
and
9 deletions
metaCode/Classes/Main/HuBiLieHomePage/Controller/CNLiveTVPlayerViewController.swift
| @@ -307,6 +307,7 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa | @@ -307,6 +307,7 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa | ||
| 307 | self.player.playerDidToEnd = { | 307 | self.player.playerDidToEnd = { |
| 308 | [weak self] asset in | 308 | [weak self] asset in |
| 309 | guard let self = self else { return } | 309 | guard let self = self else { return } |
| 310 | + | ||
| 310 | if endAssetURL == nil { | 311 | if endAssetURL == nil { |
| 311 | endAssetURL = asset.assetURL | 312 | endAssetURL = asset.assetURL |
| 312 | self.playNextIfExist() | 313 | self.playNextIfExist() |
| @@ -318,6 +319,9 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa | @@ -318,6 +319,9 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa | ||
| 318 | DispatchQueue.main.asyncAfter(deadline: delayTime) { | 319 | DispatchQueue.main.asyncAfter(deadline: delayTime) { |
| 319 | endAssetURL = nil | 320 | endAssetURL = nil |
| 320 | } | 321 | } |
| 322 | + //上报end | ||
| 323 | + CNLiveShortVideoViewModel.requestVodPlayRecordEnd(contentId: self.contentId , channelName: "yszg",model: self.vodPlayModel?.model ?? "1") | ||
| 324 | + print("\(self.contentId),\(self.vodPlayModel?.model)") | ||
| 321 | } | 325 | } |
| 322 | 326 | ||
| 323 | var urls = [URL]() | 327 | var urls = [URL]() |
| @@ -337,7 +341,7 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa | @@ -337,7 +341,7 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa | ||
| 337 | } | 341 | } |
| 338 | self.controlView.showTitle(title, cover: UIImage.imageWithColor(color: .darkGray, size: CGSize(width: 50, height: 50)), fullScreenMode: .landscape) | 342 | self.controlView.showTitle(title, cover: UIImage.imageWithColor(color: .darkGray, size: CGSize(width: 50, height: 50)), fullScreenMode: .landscape) |
| 339 | self.playTitle = title | 343 | self.playTitle = title |
| 340 | - self.controlView.vodPlayerPayBlock = {[weak self] in | 344 | + self.controlView.vodPlayerPayBlock = {[weak self] vodPlayMdl in |
| 341 | guard let self = self else { return } | 345 | guard let self = self else { return } |
| 342 | //支付按钮,拉起内购 | 346 | //支付按钮,拉起内购 |
| 343 | //成功用pay参数 刷新页面 | 347 | //成功用pay参数 刷新页面 |
| @@ -359,8 +363,7 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa | @@ -359,8 +363,7 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa | ||
| 359 | } | 363 | } |
| 360 | // 将结果转换为字符串 | 364 | // 将结果转换为字符串 |
| 361 | let yuanString = String(yuan) | 365 | let yuanString = String(yuan) |
| 362 | - | ||
| 363 | - let prdId = "com.cnlive.metaCode."+yuanString//"com.cnlive.metaCode."+"1"//+(viewcell.homeModel.albumMsgModel?.product?.iosRmb ?? "1") | 366 | + let prdId = vodPlayMdl.product?.productId ?? ""//"com.cnlive.metaCode."+yuanString//"com.cnlive.metaCode."+"1"//+(viewcell.homeModel.albumMsgModel?.product?.iosRmb ?? "1") |
| 364 | 367 | ||
| 365 | let body = self.payVodAlbumListModel?.product?.productTitle ?? "" | 368 | let body = self.payVodAlbumListModel?.product?.productTitle ?? "" |
| 366 | let total_fee = yuan*100 | 369 | let total_fee = yuan*100 |
| @@ -372,7 +375,7 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa | @@ -372,7 +375,7 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa | ||
| 372 | dataDic.setValue(total_fee, forKey: "total_fee") | 375 | dataDic.setValue(total_fee, forKey: "total_fee") |
| 373 | 376 | ||
| 374 | //后台设置一个 com.cnlive.meta.1 2 60 3 78 | 377 | //后台设置一个 com.cnlive.meta.1 2 60 3 78 |
| 375 | - //苹果内购暂时报错 验证失败支付失败 | 378 | + //苹果内购 |
| 376 | CNLivePayCostModule.showApplePayViw(withParamDict: dataDic as! [AnyHashable : Any], fromVC: currentViewController()!) {[weak self] result in | 379 | CNLivePayCostModule.showApplePayViw(withParamDict: dataDic as! [AnyHashable : Any], fromVC: currentViewController()!) {[weak self] result in |
| 377 | guard let self = self else { return } | 380 | guard let self = self else { return } |
| 378 | if result == CNLivePayCostTypeResultSucc{ | 381 | if result == CNLivePayCostTypeResultSucc{ |
| @@ -411,6 +414,7 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa | @@ -411,6 +414,7 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa | ||
| 411 | self.albumIndex = nextIdx | 414 | self.albumIndex = nextIdx |
| 412 | if let albumModel = self.albumListArr[nextIdx] as? CNLiveVodAlbumListModel{ | 415 | if let albumModel = self.albumListArr[nextIdx] as? CNLiveVodAlbumListModel{ |
| 413 | //播专辑列表下一条 | 416 | //播专辑列表下一条 |
| 417 | + self.contentId = albumModel.contentId | ||
| 414 | self.kanDianOrAlbumChangeContentApi(contentId: albumModel.contentId, title: albumModel.title, isAlbum: self.isAblumVideo, activeId: albumModel.activityId) | 418 | self.kanDianOrAlbumChangeContentApi(contentId: albumModel.contentId, title: albumModel.title, isAlbum: self.isAblumVideo, activeId: albumModel.activityId) |
| 415 | // self.changeContentApi(vodModel: albumModel) | 419 | // self.changeContentApi(vodModel: albumModel) |
| 416 | } | 420 | } |
| @@ -494,6 +498,7 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa | @@ -494,6 +498,7 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa | ||
| 494 | if status == .success{ | 498 | if status == .success{ |
| 495 | if let vodPlayModel = result as? CNLiveVodPlayModel{ | 499 | if let vodPlayModel = result as? CNLiveVodPlayModel{ |
| 496 | self.vodPlayModel = vodPlayModel | 500 | self.vodPlayModel = vodPlayModel |
| 501 | + self.controlView.vodPlayModel = vodPlayModel | ||
| 497 | self.configDataArray() | 502 | self.configDataArray() |
| 498 | self.tableView.reloadData() | 503 | self.tableView.reloadData() |
| 499 | }else{ | 504 | }else{ |
| @@ -561,6 +566,7 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa | @@ -561,6 +566,7 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa | ||
| 561 | if isReplace{ | 566 | if isReplace{ |
| 562 | self.dataArray.replaceObject(at: index, with: tempMdl as Any) | 567 | self.dataArray.replaceObject(at: index, with: tempMdl as Any) |
| 563 | }else{} | 568 | }else{} |
| 569 | + self.controlView.vodPlayModel = vodPlayModel | ||
| 564 | self.configDataArray() | 570 | self.configDataArray() |
| 565 | self.tableView.reloadData() | 571 | self.tableView.reloadData() |
| 566 | }else{ | 572 | }else{ |
| @@ -619,7 +625,8 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa | @@ -619,7 +625,8 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa | ||
| 619 | } | 625 | } |
| 620 | tempVodPlayModel?.goodsJson = vodPlayModel.goodsJson | 626 | tempVodPlayModel?.goodsJson = vodPlayModel.goodsJson |
| 621 | self.vodPlayModel = tempVodPlayModel | 627 | self.vodPlayModel = tempVodPlayModel |
| 622 | - | 628 | + self.controlView.vodPlayModel = tempVodPlayModel |
| 629 | + | ||
| 623 | //刷新url 1955_71512cfbcd5b497580732b48e26d16d6 | 630 | //刷新url 1955_71512cfbcd5b497580732b48e26d16d6 |
| 624 | CNLiveHomePageViewModel.shared.getVodVideoURL(contentId: activityId) {[weak self] result, status in | 631 | CNLiveHomePageViewModel.shared.getVodVideoURL(contentId: activityId) {[weak self] result, status in |
| 625 | guard let self = self else { return } | 632 | guard let self = self else { return } |
| @@ -651,6 +658,7 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa | @@ -651,6 +658,7 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa | ||
| 651 | guard let self = self else { return } | 658 | guard let self = self else { return } |
| 652 | if status == .success{ | 659 | if status == .success{ |
| 653 | self.vodPlayModel = vodPlayModel | 660 | self.vodPlayModel = vodPlayModel |
| 661 | + self.controlView.vodPlayModel = vodPlayModel | ||
| 654 | self.contentId = contentId | 662 | self.contentId = contentId |
| 655 | if let vodAlbumListBaseModel = result{ | 663 | if let vodAlbumListBaseModel = result{ |
| 656 | self.vodAlbumListBaseModel = vodAlbumListBaseModel | 664 | self.vodAlbumListBaseModel = vodAlbumListBaseModel |
| @@ -729,6 +737,7 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa | @@ -729,6 +737,7 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa | ||
| 729 | } | 737 | } |
| 730 | cell.selectBlock = { [weak self] model,index,kanDianListArr in | 738 | cell.selectBlock = { [weak self] model,index,kanDianListArr in |
| 731 | guard let self = self else { return } | 739 | guard let self = self else { return } |
| 740 | + //点击看点 | ||
| 732 | self.contentId = model.contentId | 741 | self.contentId = model.contentId |
| 733 | let isAblumVideo = (model.album?.albumId.count ?? 0 > 0) ? true : false | 742 | let isAblumVideo = (model.album?.albumId.count ?? 0 > 0) ? true : false |
| 734 | // let isAblumVideo = model.model == "1" ? false : true | 743 | // let isAblumVideo = model.model == "1" ? false : true |
| @@ -804,6 +813,11 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa | @@ -804,6 +813,11 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa | ||
| 804 | }else{ | 813 | }else{ |
| 805 | //没付费 | 814 | //没付费 |
| 806 | //显示付费页面 | 815 | //显示付费页面 |
| 816 | + let vodMdl = CNLiveVodPlayModel() | ||
| 817 | + vodMdl.product = vodModel.product | ||
| 818 | + vodMdl.contentId = vodModel.contentId | ||
| 819 | + vodMdl.model = vodModel.modelId | ||
| 820 | + self.controlView.vodPlayModel = vodMdl | ||
| 807 | self.controlView.payBgView.isHidden = false | 821 | self.controlView.payBgView.isHidden = false |
| 808 | self.controlView.payBgView.payBtn.setTitle("\(yuanString)元购买本专辑", for: .normal) | 822 | self.controlView.payBgView.payBtn.setTitle("\(yuanString)元购买本专辑", for: .normal) |
| 809 | //成功用pay参数 刷新页面 | 823 | //成功用pay参数 刷新页面 |
metaCode/Classes/Main/HuBiLieHomePage/View/Home/Home/CNLiveHomeFollowCell.swift
| @@ -28,6 +28,7 @@ class CNLiveHomeFollowCell:UITableViewCell{ | @@ -28,6 +28,7 @@ class CNLiveHomeFollowCell:UITableViewCell{ | ||
| 28 | iconImgView.layer.cornerRadius = 25 | 28 | iconImgView.layer.cornerRadius = 25 |
| 29 | iconImgView.clipsToBounds = true | 29 | iconImgView.clipsToBounds = true |
| 30 | iconImgView.contentMode = .scaleAspectFill | 30 | iconImgView.contentMode = .scaleAspectFill |
| 31 | + iconImgView.isUserInteractionEnabled = true | ||
| 31 | iconImgView.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(followImgViewAction))) | 32 | iconImgView.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(followImgViewAction))) |
| 32 | iconImgView.addSubview(followIconImgView) | 33 | iconImgView.addSubview(followIconImgView) |
| 33 | iconImgView.addSubview(titleLabel) | 34 | iconImgView.addSubview(titleLabel) |
| @@ -36,7 +37,7 @@ class CNLiveHomeFollowCell:UITableViewCell{ | @@ -36,7 +37,7 @@ class CNLiveHomeFollowCell:UITableViewCell{ | ||
| 36 | return iconImgView | 37 | return iconImgView |
| 37 | }() | 38 | }() |
| 38 | lazy var followIconImgView :UIImageView = { | 39 | lazy var followIconImgView :UIImageView = { |
| 39 | - let iconImgView = UIImageView(frame: CGRect(x: 20, y: (self.followImgView.height-30.0)*0.5, width: 30, height: 30)) | 40 | + let iconImgView = UIImageView(frame: CGRect(x: 20, y: (50-30.0)*0.5, width: 30, height: 30)) |
| 40 | iconImgView.image = UIImage(named: "home_followIcon") | 41 | iconImgView.image = UIImage(named: "home_followIcon") |
| 41 | iconImgView.contentMode = .scaleAspectFill | 42 | iconImgView.contentMode = .scaleAspectFill |
| 42 | return iconImgView | 43 | return iconImgView |
| @@ -87,6 +88,8 @@ class CNLiveHomeFollowCell:UITableViewCell{ | @@ -87,6 +88,8 @@ class CNLiveHomeFollowCell:UITableViewCell{ | ||
| 87 | 88 | ||
| 88 | @objc func followImgViewAction(){ | 89 | @objc func followImgViewAction(){ |
| 89 | 90 | ||
| 91 | + CNLiveDownSlideTool.pushWebAndVodVCWithContentsMdl(model: self.followModel?.modelId ?? "", contentId: self.followModel?.contentId ?? "", pid: self.followModel?.activeId ?? "", shareUrl: self.followModel?.shareUrl ?? "", thirdUrl: "", title: self.followModel?.title ?? "", s_to: "", trailerId: "", controller: navigationViewController().visibleViewController, slideModel: nil) | ||
| 92 | + | ||
| 90 | } | 93 | } |
| 91 | 94 | ||
| 92 | } | 95 | } |
metaCode/Classes/Main/HuBiLieHomePage/View/VodDetail/CNLiveZFPlayerControlView.swift
| @@ -10,10 +10,21 @@ import ZFPlayer | @@ -10,10 +10,21 @@ import ZFPlayer | ||
| 10 | 10 | ||
| 11 | //标清 2 ,高清 3 ,超清 4 | 11 | //标清 2 ,高清 3 ,超清 4 |
| 12 | typealias CNLiveVodPlayerControlLandscapeGaoqingUpdateBlock = (_ gaoqing:Int)->Void | 12 | typealias CNLiveVodPlayerControlLandscapeGaoqingUpdateBlock = (_ gaoqing:Int)->Void |
| 13 | -typealias CNLiveVodPlayerPayBlock = ()->Void | 13 | +typealias CNLiveVodPlayerPayBlock = (_ vodPlayModel : CNLiveVodPlayModel)->Void |
| 14 | 14 | ||
| 15 | class CNLiveZFPlayerControlView:ZFPlayerControlView{ | 15 | class CNLiveZFPlayerControlView:ZFPlayerControlView{ |
| 16 | 16 | ||
| 17 | + //CNLiveVodPlayModel 单集model | ||
| 18 | + var _vodPlayModel : CNLiveVodPlayModel? | ||
| 19 | + var vodPlayModel : CNLiveVodPlayModel? { | ||
| 20 | + get{ | ||
| 21 | + _vodPlayModel | ||
| 22 | + } | ||
| 23 | + set{ | ||
| 24 | + _vodPlayModel = newValue! | ||
| 25 | + } | ||
| 26 | + } | ||
| 27 | + | ||
| 17 | var controlGaoqingUpdateBlock:CNLiveVodPlayerControlLandscapeGaoqingUpdateBlock? | 28 | var controlGaoqingUpdateBlock:CNLiveVodPlayerControlLandscapeGaoqingUpdateBlock? |
| 18 | var vodPlayerPayBlock:CNLiveVodPlayerPayBlock? | 29 | var vodPlayerPayBlock:CNLiveVodPlayerPayBlock? |
| 19 | 30 | ||
| @@ -124,8 +135,7 @@ class CNLiveZFPlayerControlView:ZFPlayerControlView{ | @@ -124,8 +135,7 @@ class CNLiveZFPlayerControlView:ZFPlayerControlView{ | ||
| 124 | self.payBgView.isHidden = true | 135 | self.payBgView.isHidden = true |
| 125 | self.payBgView.payBlock = { | 136 | self.payBgView.payBlock = { |
| 126 | //拉起内购 | 137 | //拉起内购 |
| 127 | - self.vodPlayerPayBlock?() | ||
| 128 | - | 138 | + self.vodPlayerPayBlock?(self.vodPlayModel ?? CNLiveVodPlayModel()) |
| 129 | } | 139 | } |
| 130 | 140 | ||
| 131 | } | 141 | } |
metaCode/Classes/Main/HuBiLieHomePage/ViewModel/CNLiveVodPlayViewModel.swift
metaCode/Classes/Main/VideoPage/ViewModel/CNLiveShortVideoViewModel.swift
| @@ -257,6 +257,41 @@ class CNLiveShortVideoViewModel: NSObject { | @@ -257,6 +257,41 @@ class CNLiveShortVideoViewModel: NSObject { | ||
| 257 | } | 257 | } |
| 258 | } | 258 | } |
| 259 | } | 259 | } |
| 260 | + //!!!: 点播上报播放了视频 | ||
| 261 | + /// 上报播放了某一集视频 | ||
| 262 | + /// - Parameters: | ||
| 263 | + /// - contentId: 内容 id | ||
| 264 | + /// - channelName: | ||
| 265 | + /// - model: | ||
| 266 | + static func requestVodPlayRecordEnd(contentId: String, channelName: String,model:String) { | ||
| 267 | + let param = NSMutableDictionary() | ||
| 268 | + param.setValue("", forKey: "schedule") | ||
| 269 | + param.setValue(contentId, forKey: "contentId") | ||
| 270 | + param.setValue(UserInfoManager.shared.userInfo.uid, forKey: "sid") | ||
| 271 | + param.setValue(channelName, forKey: "channelName") | ||
| 272 | + param.setValue(model, forKey: "model") | ||
| 273 | + | ||
| 274 | + let custom_param = NSMutableDictionary() | ||
| 275 | + custom_param.setValue(CNLiveMCEnvironmentManager.shared.appId_wjj, forKey: "appId") | ||
| 276 | + custom_param.setValue(CNLiveMCEnvironmentManager.shared.appKey_wjj, forKey: "appKey") | ||
| 277 | + CNLiveNetworking.setAllowRequestDefaultArgument(true) | ||
| 278 | + CNLiveNetworking.setupShowDataResult(false) | ||
| 279 | + CNLiveNetworking.setupShowResult(true) | ||
| 280 | + CNLiveNetworking.setupCustomParam(custom_param as? [String : String]) | ||
| 281 | + CNLiveNetworking.requestNetwork(with: .POST, urlString: APPBaseCMSClassUrl+"/recordApi/end", param: param as! [String : String], cacheType: .networkOnly) { task, result, error in | ||
| 282 | + hiddenLoading() | ||
| 283 | + if (error == nil) { | ||
| 284 | + let resp = result as! NSDictionary | ||
| 285 | + let errorCode = "\(resp["errorCode"] ?? "0")" | ||
| 286 | + if (errorCode == "0") { | ||
| 287 | + print(resp) | ||
| 288 | + } else { | ||
| 289 | + } | ||
| 290 | + } else { | ||
| 291 | + } | ||
| 292 | + } | ||
| 293 | + } | ||
| 294 | + | ||
| 260 | 295 | ||
| 261 | //!!!: 评论相关 | 296 | //!!!: 评论相关 |
| 262 | 297 |