Commit ff7c974c1df7a98ea4b5ba53efbe2924fb42c633

Authored by “张旭”
1 parent 86da6248

专辑和单集 付费后刷新页面

metaCode/Classes/Main/HuBiLieHomePage/Controller/CNLiveTVPlayerViewController.swift
@@ -26,6 +26,9 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa @@ -26,6 +26,9 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa
26 var isPayZhuanJi = false 26 var isPayZhuanJi = false
27 var payVodProductModel:CNLiveAlbumProductModel? 27 var payVodProductModel:CNLiveAlbumProductModel?
28 28
  29 + //当前选择内容是否需要付费
  30 + var currentPlayIsNeedPay = false
  31 +
29 32
30 var player: ZFPlayerController! 33 var player: ZFPlayerController!
31 //当前内容id 34 //当前内容id
@@ -254,7 +257,9 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa @@ -254,7 +257,9 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa
254 self.player.currentPlayerManager.pause() 257 self.player.currentPlayerManager.pause()
255 } 258 }
256 @objc func appDidEnterPlayGround() { 259 @objc func appDidEnterPlayGround() {
257 - self.player.currentPlayerManager.play() 260 + if !self.currentPlayIsNeedPay{
  261 + self.player.currentPlayerManager.play()
  262 + }
258 } 263 }
259 264
260 265
@@ -329,8 +334,33 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa @@ -329,8 +334,33 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa
329 334
330 } 335 }
331 336
  337 + //设置付费参数
  338 + func setPayParams(payVodAlbumListModel:CNLiveVodAlbumListModel?,payContentId:String,payAid:String,payAlbumListArr:NSMutableArray,payIndex:Int,payTitle:String,payIsAlbum:Bool,payActivityId:String,isPayZhuanJi:Bool,payVodProductModel:CNLiveAlbumProductModel?){
  339 + self.payVodAlbumListModel = payVodAlbumListModel
  340 + self.payAid = payAid
  341 + self.payContentId = payContentId
  342 + self.payAlbumListArr = payAlbumListArr
  343 + self.payIndex = payIndex
  344 + self.payTitle = payTitle
  345 + self.payIsAlbum = payIsAlbum
  346 + self.payActivityId = payActivityId
  347 + self.isPayZhuanJi = isPayZhuanJi
  348 + self.payVodProductModel = payVodProductModel
  349 + self.player.allowOrentitaionRotation = false
  350 + }
  351 + func resetPayParams(){
  352 + //重置参数成功用pay参数
  353 + self.payVodAlbumListModel = nil
  354 + self.payAid = ""
  355 + self.payContentId = ""
  356 + self.payAlbumListArr = NSMutableArray()
  357 + self.payIndex = 0
  358 + self.payTitle = ""
  359 + self.payIsAlbum = false
  360 + self.payActivityId = ""
  361 + self.player.allowOrentitaionRotation = true
  362 + }
332 // MARK: - 播放相关 363 // MARK: - 播放相关
333 -  
334 func setupPlayer(){ 364 func setupPlayer(){
335 let playerManager = ZFAVPlayerManager() 365 let playerManager = ZFAVPlayerManager()
336 playerManager.shouldAutoPlay = true 366 playerManager.shouldAutoPlay = true
@@ -411,10 +441,24 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa @@ -411,10 +441,24 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa
411 } 441 }
412 } 442 }
413 443
  444 + //true当前播放的专辑 false看点
  445 + let isAblumVideo = (self.vodPlayModel?.album?.albumId.count ?? 0 > 0) ? true : false
  446 +
414 var yuanString = "" 447 var yuanString = ""
415 let isPaid = CNLivePlayerTool.isPaid(product: self.vodPlayModel?.product) 448 let isPaid = CNLivePlayerTool.isPaid(product: self.vodPlayModel?.product)
416 if isPaid{ 449 if isPaid{
417 //需要付费 450 //需要付费
  451 + self.currentPlayIsNeedPay = true
  452 + if isAblumVideo{
  453 + let payVodAlbumListModel = self.vodAlbumListBaseModel?.list.count ?? 0 > self.albumIndex ? self.vodAlbumListBaseModel?.list[self.albumIndex] : nil
  454 + var payAlbumListArr = NSMutableArray()
  455 + if self.vodAlbumListBaseModel?.list.count ?? 0 > 0{
  456 + payAlbumListArr = NSMutableArray(array: self.vodAlbumListBaseModel!.list)
  457 + }
  458 + self.setPayParams(payVodAlbumListModel: payVodAlbumListModel, payContentId: self.vodPlayModel?.cid ?? (self.vodPlayModel?.contentId ?? ""), payAid: self.vodPlayModel?.albumId ?? "", payAlbumListArr: payAlbumListArr, payIndex: self.albumIndex, payTitle: title, payIsAlbum: true, payActivityId: self.vodPlayModel?.contentId ?? "", isPayZhuanJi: true, payVodProductModel: self.vodPlayModel?.product)
  459 + }else{
  460 + self.setPayParams(payVodAlbumListModel: nil, payContentId: self.vodPlayModel?.cid ?? "", payAid: self.vodPlayModel?.albumId ?? "", payAlbumListArr: NSMutableArray(), payIndex: albumIndex, payTitle: title, payIsAlbum: false, payActivityId: self.vodPlayModel?.contentId ?? "", isPayZhuanJi: false, payVodProductModel: self.vodPlayModel?.product)
  461 + }
418 462
419 var urls = [URL]() 463 var urls = [URL]()
420 urls.append(self.url!) 464 urls.append(self.url!)
@@ -441,12 +485,13 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa @@ -441,12 +485,13 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa
441 yuanString = String(yuan) 485 yuanString = String(yuan)
442 }else{ 486 }else{
443 //免费或者付过费了 487 //免费或者付过费了
  488 + self.currentPlayIsNeedPay = false
  489 + self.resetPayParams()
444 self.controlView.payBgView.isHidden = true 490 self.controlView.payBgView.isHidden = true
445 isPayZhuanJi = true 491 isPayZhuanJi = true
446 // self.playWithUrlAndTitle(url: self.url!.absoluteString, title: title) 492 // self.playWithUrlAndTitle(url: self.url!.absoluteString, title: title)
447 } 493 }
448 - //true当前播放的专辑 false看点  
449 - let isAblumVideo = (self.vodPlayModel?.album?.albumId.count ?? 0 > 0) ? true : false 494 +
450 var vodAlbumListModel:CNLiveVodAlbumListModel? 495 var vodAlbumListModel:CNLiveVodAlbumListModel?
451 if self.albumListArr.count > 0{ 496 if self.albumListArr.count > 0{
452 if let vodAlbumListMdl = self.albumListArr[self.albumIndex] as? CNLiveVodAlbumListModel{ 497 if let vodAlbumListMdl = self.albumListArr[self.albumIndex] as? CNLiveVodAlbumListModel{
@@ -615,7 +660,9 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa @@ -615,7 +660,9 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa
615 self.contentId = self.payContentId 660 self.contentId = self.payContentId
616 self.refreshVodData(isAblumVideo: self.payIsAlbum) 661 self.refreshVodData(isAblumVideo: self.payIsAlbum)
617 self.controlView.payBgView.isHidden = true 662 self.controlView.payBgView.isHidden = true
618 - self.player.allowOrentitaionRotation = true 663 +
  664 + //重置参数成功用pay参数
  665 + self.resetPayParams()
619 } 666 }
620 667
621 } 668 }
@@ -1299,6 +1346,7 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa @@ -1299,6 +1346,7 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa
1299 1346
1300 if isPayZhuanJi{ 1347 if isPayZhuanJi{
1301 //已付费 1348 //已付费
  1349 + self.currentPlayIsNeedPay = false
1302 if isAblumVideo{ 1350 if isAblumVideo{
1303 //点击专辑 1351 //点击专辑
1304 self.controlView.payBgView.isHidden = isPayZhuanJi 1352 self.controlView.payBgView.isHidden = isPayZhuanJi
@@ -1330,6 +1378,7 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa @@ -1330,6 +1378,7 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa
1330 } 1378 }
1331 }else{ 1379 }else{
1332 //未付费 1380 //未付费
  1381 + self.currentPlayIsNeedPay = true
1333 if isAblumVideo{ 1382 if isAblumVideo{
1334 //点击专辑 1383 //点击专辑
1335 //显示付费页面 1384 //显示付费页面
@@ -1348,15 +1397,17 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa @@ -1348,15 +1397,17 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa
1348 self.isPlayAblumOrKandian = isPlayAblumOrKandian 1397 self.isPlayAblumOrKandian = isPlayAblumOrKandian
1349 1398
1350 //成功用pay参数 刷新页面 1399 //成功用pay参数 刷新页面
1351 - self.payVodAlbumListModel = payVodAlbumListModel  
1352 - self.payAid = payVodAlbumListModel?.albumId ?? ""  
1353 - self.payContentId = payVodAlbumListModel?.contentId ?? ""  
1354 - self.payAlbumListArr = albumListArray  
1355 - self.payIndex = albumSelectIndex  
1356 - self.payTitle = modelTitle  
1357 - self.payIsAlbum = isAblumVideo  
1358 - self.payActivityId = mdlActiveId  
1359 - self.player.allowOrentitaionRotation = isPayZhuanJi 1400 + self.setPayParams(payVodAlbumListModel: payVodAlbumListModel, payContentId: payVodAlbumListModel?.contentId ?? "", payAid: payVodAlbumListModel?.albumId ?? "", payAlbumListArr: albumListArray, payIndex: albumSelectIndex, payTitle: modelTitle, payIsAlbum: isAblumVideo, payActivityId: mdlActiveId, isPayZhuanJi: true, payVodProductModel: mdlProduct)
  1401 +// //成功用pay参数 刷新页面
  1402 +// self.payVodAlbumListModel = payVodAlbumListModel
  1403 +// self.payAid = payVodAlbumListModel?.albumId ?? ""
  1404 +// self.payContentId = payVodAlbumListModel?.contentId ?? ""
  1405 +// self.payAlbumListArr = albumListArray
  1406 +// self.payIndex = albumSelectIndex
  1407 +// self.payTitle = modelTitle
  1408 +// self.payIsAlbum = isAblumVideo
  1409 +// self.payActivityId = mdlActiveId
  1410 +// self.player.allowOrentitaionRotation = isPayZhuanJi
1360 1411
1361 //更新选集-专辑列表 1412 //更新选集-专辑列表
1362 self.controlView.xuanjiBgView.currSeleIdx = xuanjiBgViewCurrSeleIdx 1413 self.controlView.xuanjiBgView.currSeleIdx = xuanjiBgViewCurrSeleIdx
@@ -1379,13 +1430,14 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa @@ -1379,13 +1430,14 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa
1379 self.isPlayAblumOrKandian = isPlayAblumOrKandian 1430 self.isPlayAblumOrKandian = isPlayAblumOrKandian
1380 1431
1381 //成功用pay参数 刷新页面 1432 //成功用pay参数 刷新页面
1382 - self.payVodProductModel = mdlProduct  
1383 - self.payContentId = mdlContentId  
1384 - self.payIndex = albumSelectIndex  
1385 - self.payTitle = modelTitle  
1386 - self.payIsAlbum = isAblumVideo  
1387 - self.payActivityId = mdlActiveId  
1388 - self.player.allowOrentitaionRotation = isPayZhuanJi 1433 + self.setPayParams(payVodAlbumListModel: nil, payContentId: mdlContentId, payAid: "", payAlbumListArr: NSMutableArray(), payIndex: albumSelectIndex, payTitle: modelTitle, payIsAlbum: isAblumVideo, payActivityId: mdlActiveId, isPayZhuanJi: false, payVodProductModel: mdlProduct)
  1434 +// self.payVodProductModel = mdlProduct
  1435 +// self.payContentId = mdlContentId
  1436 +// self.payIndex = albumSelectIndex
  1437 +// self.payTitle = modelTitle
  1438 +// self.payIsAlbum = isAblumVideo
  1439 +// self.payActivityId = mdlActiveId
  1440 +// self.player.allowOrentitaionRotation = isPayZhuanJi
1389 //更新选集-看点列表 1441 //更新选集-看点列表
1390 self.controlView.xuanjiBgView.currSeleIdx = xuanjiBgViewCurrSeleIdx 1442 self.controlView.xuanjiBgView.currSeleIdx = xuanjiBgViewCurrSeleIdx
1391 self.controlView.xuanjiBgView.kanDianListArr = kanDianListArray 1443 self.controlView.xuanjiBgView.kanDianListArr = kanDianListArray
metaCode/Classes/Main/HuBiLieHomePage/Util/CNLiveDownSlideTool.swift
@@ -329,7 +329,7 @@ class CNLiveDownSlideTool:NSObject{ @@ -329,7 +329,7 @@ class CNLiveDownSlideTool:NSObject{
329 }else{ 329 }else{
330 //单集 330 //单集
331 //获取play 331 //获取play
332 - CNLiveDownSlideTool.getVodPlayApi(contentId: contentId){ result, status in 332 + CNLiveDownSlideTool.getVodPlayApi(contentId: contentId.count > 0 ? contentId : seleContentId){ result, status in
333 if status == .success{ 333 if status == .success{
334 if let vodModel = result as? CNLiveVodPlayModel{ 334 if let vodModel = result as? CNLiveVodPlayModel{
335 //获得点播url 335 //获得点播url
@@ -338,7 +338,7 @@ class CNLiveDownSlideTool:NSObject{ @@ -338,7 +338,7 @@ class CNLiveDownSlideTool:NSObject{
338 hiddenLoading() 338 hiddenLoading()
339 if status == .success{ 339 if status == .success{
340 if let url = result as? String{ 340 if let url = result as? String{
341 - resultBlock(vodModel,contentId,url,nil,.success) 341 + resultBlock(vodModel,vodModel.contentId,url,nil,.success)
342 } 342 }
343 }else{ 343 }else{
344 344