Commit 479d4634bd346116253dff3c8268b3cd51f68b27
1 parent
88a8de26
切换 看点 ,剧集 更新点赞 收藏 和播放器 ,自动播放下一集
Showing
5 changed files
with
306 additions
and
40 deletions
metaCode/Classes/Main/HomePages/ViewModel/CNLiveHomePageViewModel.swift
| @@ -29,7 +29,7 @@ class CNLiveHomePageViewModel:NSObject,URLSessionTaskDelegate{ | @@ -29,7 +29,7 @@ class CNLiveHomePageViewModel:NSObject,URLSessionTaskDelegate{ | ||
| 29 | 29 | ||
| 30 | let uuid = CNLiveBusinessTools.getUidForStat(Date()) | 30 | let uuid = CNLiveBusinessTools.getUidForStat(Date()) |
| 31 | 31 | ||
| 32 | - let shortVersion = Bundle.main.infoDictionary!["CFBundleShortVersionString"] as! String | 32 | + let shortVersion = "2.3.8"//Bundle.main.infoDictionary!["CFBundleShortVersionString"] as! String |
| 33 | 33 | ||
| 34 | 34 | ||
| 35 | let param = NSMutableDictionary() | 35 | let param = NSMutableDictionary() |
| @@ -99,7 +99,7 @@ class CNLiveHomePageViewModel:NSObject,URLSessionTaskDelegate{ | @@ -99,7 +99,7 @@ class CNLiveHomePageViewModel:NSObject,URLSessionTaskDelegate{ | ||
| 99 | completionHandler(nil) | 99 | completionHandler(nil) |
| 100 | } | 100 | } |
| 101 | 101 | ||
| 102 | - //点播详情 | 102 | + //点播详情 album.albumId为""是点播 ,否则专辑 |
| 103 | static func requestGetVodPlayApi( contentId:String,sid:String,resultBlock: @escaping downSlideResultBlock) { | 103 | static func requestGetVodPlayApi( contentId:String,sid:String,resultBlock: @escaping downSlideResultBlock) { |
| 104 | let param = NSMutableDictionary() | 104 | let param = NSMutableDictionary() |
| 105 | param.setValue(contentId, forKey: "contentId") | 105 | param.setValue(contentId, forKey: "contentId") |
metaCode/Classes/Main/HuBiLieHomePage/Controller/CNLiveTVPlayerViewController.swift
| @@ -13,10 +13,27 @@ import CNLiveShareToolKit | @@ -13,10 +13,27 @@ import CNLiveShareToolKit | ||
| 13 | 13 | ||
| 14 | class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITableViewDelegate{ | 14 | class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITableViewDelegate{ |
| 15 | 15 | ||
| 16 | + var player: ZFPlayerController! | ||
| 16 | //当前内容id | 17 | //当前内容id |
| 17 | var contentId = "" | 18 | var contentId = "" |
| 18 | var playTitle = "" | 19 | var playTitle = "" |
| 19 | var isSeek = false | 20 | var isSeek = false |
| 21 | + //当前播放列表 专辑true / 看点false | ||
| 22 | + var isPlayAblumOrKandian = false | ||
| 23 | + var isAblumVideo = false | ||
| 24 | + //专辑列表数组 播放专辑时用 | ||
| 25 | + lazy var albumListArr: NSMutableArray = { | ||
| 26 | + var dataArray = NSMutableArray() | ||
| 27 | + return dataArray | ||
| 28 | + }() | ||
| 29 | + var albumIndex:Int = 0//当前专辑播放index | ||
| 30 | + | ||
| 31 | + //看点列表数组 播放看点时用 | ||
| 32 | + lazy var kanDianListArr: NSMutableArray = { | ||
| 33 | + var dataArray = NSMutableArray() | ||
| 34 | + return dataArray | ||
| 35 | + }() | ||
| 36 | + var kanDianIndex:Int = -1//当前看点播放index | ||
| 20 | 37 | ||
| 21 | //CNLiveVodPlayModel 单集model | 38 | //CNLiveVodPlayModel 单集model |
| 22 | var _vodPlayModel : CNLiveVodPlayModel? | 39 | var _vodPlayModel : CNLiveVodPlayModel? |
| @@ -29,7 +46,7 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa | @@ -29,7 +46,7 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa | ||
| 29 | } | 46 | } |
| 30 | } | 47 | } |
| 31 | 48 | ||
| 32 | - //CNLiveVodPlayModel 专辑列表model | 49 | + // 专辑列表model |
| 33 | var _vodAlbumListBaseModel : CNLiveVodAlbumListBaseModel? | 50 | var _vodAlbumListBaseModel : CNLiveVodAlbumListBaseModel? |
| 34 | var vodAlbumListBaseModel : CNLiveVodAlbumListBaseModel? { | 51 | var vodAlbumListBaseModel : CNLiveVodAlbumListBaseModel? { |
| 35 | get{ | 52 | get{ |
| @@ -131,8 +148,6 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa | @@ -131,8 +148,6 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa | ||
| 131 | controlView.showCustomStatusBar = true | 148 | controlView.showCustomStatusBar = true |
| 132 | return controlView | 149 | return controlView |
| 133 | }() | 150 | }() |
| 134 | - var player: ZFPlayerController! | ||
| 135 | - var isAblumVideo = false | ||
| 136 | override func viewDidLoad() { | 151 | override func viewDidLoad() { |
| 137 | super.viewDidLoad() | 152 | super.viewDidLoad() |
| 138 | view.backgroundColor = .black | 153 | view.backgroundColor = .black |
| @@ -180,12 +195,17 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa | @@ -180,12 +195,17 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa | ||
| 180 | // self.addRefreshView() | 195 | // self.addRefreshView() |
| 181 | self.configDataArray() | 196 | self.configDataArray() |
| 182 | self.isAblumVideo = false | 197 | self.isAblumVideo = false |
| 183 | - if let albumModel = self.vodAlbumListBaseModel{ | 198 | + self.isPlayAblumOrKandian = false |
| 199 | + | ||
| 200 | +// if let albumModel = self.vodAlbumListBaseModel{ | ||
| 201 | + if self.vodPlayModel?.album?.albumId.count ?? 0 > 0{ | ||
| 184 | //专辑 | 202 | //专辑 |
| 185 | self.isAblumVideo = true | 203 | self.isAblumVideo = true |
| 204 | + self.isPlayAblumOrKandian = true | ||
| 186 | }else{ | 205 | }else{ |
| 187 | //单集 | 206 | //单集 |
| 188 | self.isAblumVideo = false | 207 | self.isAblumVideo = false |
| 208 | + self.isPlayAblumOrKandian = false | ||
| 189 | } | 209 | } |
| 190 | } | 210 | } |
| 191 | 211 | ||
| @@ -269,11 +289,22 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa | @@ -269,11 +289,22 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa | ||
| 269 | guard let self = self else { return } | 289 | guard let self = self else { return } |
| 270 | 290 | ||
| 271 | } | 291 | } |
| 292 | + var endAssetURL:URL? | ||
| 272 | /// 播放完成 | 293 | /// 播放完成 |
| 273 | self.player.playerDidToEnd = { | 294 | self.player.playerDidToEnd = { |
| 274 | [weak self] asset in | 295 | [weak self] asset in |
| 275 | guard let self = self else { return } | 296 | guard let self = self else { return } |
| 276 | - self.playNextIfExist() | 297 | + if endAssetURL == nil { |
| 298 | + endAssetURL = asset.assetURL | ||
| 299 | + self.playNextIfExist() | ||
| 300 | + }else{ | ||
| 301 | + //一个视频回调 两次end | ||
| 302 | + endAssetURL = nil | ||
| 303 | + } | ||
| 304 | + let delayTime = DispatchTime.now()+3 | ||
| 305 | + DispatchQueue.main.asyncAfter(deadline: delayTime) { | ||
| 306 | + endAssetURL = nil | ||
| 307 | + } | ||
| 277 | } | 308 | } |
| 278 | 309 | ||
| 279 | var urls = [URL]() | 310 | var urls = [URL]() |
| @@ -308,14 +339,42 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa | @@ -308,14 +339,42 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa | ||
| 308 | } | 339 | } |
| 309 | 340 | ||
| 310 | func playNextIfExist(){ | 341 | func playNextIfExist(){ |
| 311 | - //当前播放的是 专辑列表 ,播专辑列表下一条 | ||
| 312 | - //当前播放的是 看点列表 ,播看点列表下一条 | ||
| 313 | 342 | ||
| 314 | - if self.isAblumVideo{ | ||
| 315 | - //播专辑列表下一条 | 343 | + if self.isAblumVideo && self.isPlayAblumOrKandian{ |
| 344 | + //当前播放的是 专辑列表 ,播专辑列表下一条 | ||
| 345 | + let nextIdx = self.albumIndex + 1 | ||
| 346 | + if nextIdx < self.albumListArr.count{ | ||
| 347 | + self.albumIndex = nextIdx | ||
| 348 | + if let albumModel = self.albumListArr[nextIdx] as? CNLiveVodAlbumListModel{ | ||
| 349 | + //播专辑列表下一条 | ||
| 350 | + self.kanDianOrAlbumChangeContentApi(contentId: albumModel.contentId, title: albumModel.title, isAlbum: self.isAblumVideo, activeId: albumModel.activityId) | ||
| 351 | +// self.changeContentApi(vodModel: albumModel) | ||
| 352 | + } | ||
| 353 | + | ||
| 354 | + }else{ | ||
| 355 | +// self.player.stop() | ||
| 356 | + } | ||
| 316 | 357 | ||
| 317 | }else{ | 358 | }else{ |
| 318 | - // | 359 | + //当前播放的是 看点列表 ,播看点列表下一条 |
| 360 | + let nextIdx = self.kanDianIndex + 1 | ||
| 361 | + if nextIdx < self.kanDianListArr.count{ | ||
| 362 | + self.kanDianIndex = nextIdx | ||
| 363 | + self.albumIndex = -1 | ||
| 364 | + if let albumModel = self.kanDianListArr[nextIdx] as? CNLiveVodPlayBlockListListModel{ | ||
| 365 | + //播列表下一条 | ||
| 366 | + let isAblumVideo = (albumModel.album?.albumId.count ?? 0 > 0) ? true : false | ||
| 367 | +// if isAblumVideo{ | ||
| 368 | + self.kanDianOrAlbumChangeContentApi(contentId: albumModel.contentId, title: albumModel.title, isAlbum: isAblumVideo, activeId: albumModel.pid) | ||
| 369 | +// }else{ | ||
| 370 | +// self.kanDianOrAlbumChangeContentApi(contentId: albumModel.contentId, title: albumModel.title, isAlbum: isAblumVideo, activeId: albumModel.pid) | ||
| 371 | +// } | ||
| 372 | +// self.changeContentApi(vodModel: albumModel) | ||
| 373 | + } | ||
| 374 | + | ||
| 375 | + }else{ | ||
| 376 | +// self.player.stop() | ||
| 377 | + } | ||
| 319 | } | 378 | } |
| 320 | // if (!self.player.isLastAssetURL) { | 379 | // if (!self.player.isLastAssetURL) { |
| 321 | // [self.player playTheNext]; | 380 | // [self.player playTheNext]; |
| @@ -386,29 +445,58 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa | @@ -386,29 +445,58 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa | ||
| 386 | self.player.stop() | 445 | self.player.stop() |
| 387 | } | 446 | } |
| 388 | 447 | ||
| 389 | - // MARK: -专辑列表切换某集 ,刷新看点和电商 | ||
| 390 | - func changeContentApi(vodModel:CNLiveVodAlbumListModel){ | ||
| 391 | - | 448 | + // MARK: - 专辑/看点 列表切换某集,只刷新播放器和点赞收藏 |
| 449 | + func kanDianOrAlbumChangeContentApi(contentId:String,title:String,isAlbum:Bool,activeId:String){ | ||
| 450 | +// if isAlbum{ | ||
| 451 | + self.changeContentApi(activityId: activeId, title: title, contentId: contentId) | ||
| 452 | +// }else{ | ||
| 453 | +// self.kanDianChangeContentApi(contentId: contentId, title: title) | ||
| 454 | +// } | ||
| 455 | + } | ||
| 456 | + // MARK: - 看点列表切换某集 只刷新播放器和点赞收藏 | ||
| 457 | + func kanDianChangeContentApi(contentId:String,title:String){ | ||
| 458 | + self.isPlayAblumOrKandian = false | ||
| 392 | //刷新url | 459 | //刷新url |
| 393 | - CNLiveHomePageViewModel.shared.getVodVideoURL(contentId: vodModel.activityId) {[weak self] result, status in | 460 | + CNLiveHomePageViewModel.shared.getVodVideoURL(contentId: contentId) {[weak self] result, status in |
| 394 | guard let self = self else { return } | 461 | guard let self = self else { return } |
| 395 | if status == .success | 462 | if status == .success |
| 396 | { | 463 | { |
| 397 | if let url = result as? String{ | 464 | if let url = result as? String{ |
| 398 | - self.playWithUrlAndTitle(url: url, title: vodModel.title) | 465 | + self.playWithUrlAndTitle(url: url, title: title) |
| 466 | + self.url = URL(string: url) | ||
| 399 | } | 467 | } |
| 400 | }else{ | 468 | }else{ |
| 401 | 469 | ||
| 402 | } | 470 | } |
| 403 | } | 471 | } |
| 404 | 472 | ||
| 405 | - | ||
| 406 | //play接口刷新 看点和电商 | 473 | //play接口刷新 看点和电商 |
| 407 | - CNLiveDownSlideTool.getVodPlayApi(contentId: vodModel.contentId) {[weak self] result, status in | 474 | + CNLiveDownSlideTool.getVodPlayApi(contentId: contentId) {[weak self] result, status in |
| 408 | guard let self = self else { return } | 475 | guard let self = self else { return } |
| 409 | if status == .success{ | 476 | if status == .success{ |
| 410 | if let vodPlayModel = result as? CNLiveVodPlayModel{ | 477 | if let vodPlayModel = result as? CNLiveVodPlayModel{ |
| 411 | - self.vodPlayModel = vodPlayModel | 478 | +// self.vodPlayModel = vodPlayModel |
| 479 | + //单集有值-简介 | ||
| 480 | + var index = 0 | ||
| 481 | + var isReplace = false | ||
| 482 | + var tempMdl:CNLiveVodPlayBlockListModel? | ||
| 483 | + for (idx,mdl) in self.dataArray.enumerated(){ | ||
| 484 | + if var tempVodMdl = mdl as? CNLiveVodPlayBlockListModel{ | ||
| 485 | + if tempVodMdl.type == "5"{//点播详情数据 | ||
| 486 | + | ||
| 487 | + for (_,vodMdl) in vodPlayModel.blockList.enumerated(){ | ||
| 488 | + if vodMdl.type == "5"{ | ||
| 489 | + tempMdl = vodMdl | ||
| 490 | + index = idx | ||
| 491 | + isReplace = true | ||
| 492 | + } | ||
| 493 | + } | ||
| 494 | + } | ||
| 495 | + } | ||
| 496 | + } | ||
| 497 | + if isReplace{ | ||
| 498 | + self.dataArray.replaceObject(at: index, with: tempMdl as Any) | ||
| 499 | + }else{} | ||
| 412 | self.configDataArray() | 500 | self.configDataArray() |
| 413 | self.tableView.reloadData() | 501 | self.tableView.reloadData() |
| 414 | }else{ | 502 | }else{ |
| @@ -420,6 +508,79 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa | @@ -420,6 +508,79 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa | ||
| 420 | } | 508 | } |
| 421 | 509 | ||
| 422 | } | 510 | } |
| 511 | + | ||
| 512 | + | ||
| 513 | + // MARK: -专辑列表切换某集 ,刷新看点和电商 | ||
| 514 | + func changeContentApi(activityId:String,title:String,contentId:String){ | ||
| 515 | +// self.isPlayAblumOrKandian = true | ||
| 516 | + | ||
| 517 | + //play接口刷新 看点和电商 1350755 | ||
| 518 | + CNLiveDownSlideTool.getVodPlayApi(contentId: contentId) {[weak self] result, status in | ||
| 519 | + guard let self = self else { return } | ||
| 520 | + if status == .success{ | ||
| 521 | + if var vodPlayModel = result as? CNLiveVodPlayModel{ | ||
| 522 | +// self.vodPlayModel = vodPlayModel | ||
| 523 | + //单集有值-简介 | ||
| 524 | + var temp5Mdl:CNLiveVodPlayBlockListModel? | ||
| 525 | + var temp2Mdl:CNLiveVodPlayBlockListModel? | ||
| 526 | + | ||
| 527 | + var tempVodPlayModel = self.vodPlayModel | ||
| 528 | + for (_,vodMdl) in vodPlayModel.blockList.enumerated(){ | ||
| 529 | + if vodMdl.type == "5"{ | ||
| 530 | + temp5Mdl = vodMdl | ||
| 531 | + } | ||
| 532 | + if vodMdl.type == "2"{ | ||
| 533 | + temp2Mdl = vodMdl | ||
| 534 | + } | ||
| 535 | + } | ||
| 536 | + for(index,vodModel) in tempVodPlayModel!.blockList.enumerated(){ | ||
| 537 | + if self.isPlayAblumOrKandian{ | ||
| 538 | + //切换剧集时, 调用play接口, 更新片花列表和商品列表 | ||
| 539 | + if temp2Mdl != nil{ | ||
| 540 | + if vodModel.type == "2"{//更新片花 | ||
| 541 | + tempVodPlayModel!.blockList[index] = temp2Mdl! | ||
| 542 | + } | ||
| 543 | + } | ||
| 544 | + | ||
| 545 | + }else{ | ||
| 546 | + //切换看点时, 调用play接口, 只更新商品列表 | ||
| 547 | + } | ||
| 548 | + | ||
| 549 | + //更新简介里的 点赞和收藏 简介 | ||
| 550 | + if temp5Mdl != nil{ | ||
| 551 | + if vodModel.type == "5"{ | ||
| 552 | + tempVodPlayModel!.blockList[index] = temp5Mdl! | ||
| 553 | + } | ||
| 554 | + } | ||
| 555 | + } | ||
| 556 | + tempVodPlayModel?.goodsJson = vodPlayModel.goodsJson | ||
| 557 | + self.vodPlayModel = tempVodPlayModel | ||
| 558 | + | ||
| 559 | + //刷新url 1955_71512cfbcd5b497580732b48e26d16d6 | ||
| 560 | + CNLiveHomePageViewModel.shared.getVodVideoURL(contentId: activityId) {[weak self] result, status in | ||
| 561 | + guard let self = self else { return } | ||
| 562 | + if status == .success | ||
| 563 | + { | ||
| 564 | + if let url = result as? String{ | ||
| 565 | + self.playWithUrlAndTitle(url: url, title: title) | ||
| 566 | + self.url = URL(string: url) | ||
| 567 | + } | ||
| 568 | + }else{ | ||
| 569 | + | ||
| 570 | + } | ||
| 571 | + } | ||
| 572 | + | ||
| 573 | + self.configDataArray() | ||
| 574 | + self.tableView.reloadData() | ||
| 575 | + }else{ | ||
| 576 | + | ||
| 577 | + } | ||
| 578 | + }else{ | ||
| 579 | + | ||
| 580 | + } | ||
| 581 | + } | ||
| 582 | + | ||
| 583 | + } | ||
| 423 | // MARK: - 刷新 整个页面 | 584 | // MARK: - 刷新 整个页面 |
| 424 | func refreshVodData(isAblumVideo:Bool){ | 585 | func refreshVodData(isAblumVideo:Bool){ |
| 425 | CNLiveDownSlideTool.getVodData(contentId: self.contentId, isAblumVideo: isAblumVideo) {[weak self] vodPlayModel, contentId,url, result, status in | 586 | CNLiveDownSlideTool.getVodData(contentId: self.contentId, isAblumVideo: isAblumVideo) {[weak self] vodPlayModel, contentId,url, result, status in |
| @@ -494,17 +655,25 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa | @@ -494,17 +655,25 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa | ||
| 494 | let cell = CNLiveVodTrailersCell() | 655 | let cell = CNLiveVodTrailersCell() |
| 495 | return cell | 656 | return cell |
| 496 | } | 657 | } |
| 497 | - cell.currSeleIdx = -1 | 658 | + cell.currSeleIdx = self.kanDianIndex//-1 |
| 498 | cell.vodPlayBlockListModel = vodPlayBlockListModel | 659 | cell.vodPlayBlockListModel = vodPlayBlockListModel |
| 499 | cell.expandBlock = { [weak self] model in | 660 | cell.expandBlock = { [weak self] model in |
| 500 | guard let self = self else { return } | 661 | guard let self = self else { return } |
| 501 | self.trailersCellDetailBtnAction(vodPlayBlockListModel: model) | 662 | self.trailersCellDetailBtnAction(vodPlayBlockListModel: model) |
| 502 | } | 663 | } |
| 503 | - cell.selectBlock = { [weak self] model in | 664 | + cell.selectBlock = { [weak self] model,index,kanDianListArr in |
| 504 | guard let self = self else { return } | 665 | guard let self = self else { return } |
| 505 | self.contentId = model.contentId | 666 | self.contentId = model.contentId |
| 506 | - let isAblumVideo = model.model == "1" ? false : true | ||
| 507 | - self.refreshVodData(isAblumVideo: isAblumVideo) | 667 | + let isAblumVideo = (model.album?.albumId.count ?? 0 > 0) ? true : false |
| 668 | +// let isAblumVideo = model.model == "1" ? false : true | ||
| 669 | + self.albumIndex = -1 | ||
| 670 | + self.kanDianIndex = index | ||
| 671 | + self.kanDianListArr = kanDianListArr | ||
| 672 | + //只更新 此视频的长id,换url(不管是不是专辑) | ||
| 673 | + self.isPlayAblumOrKandian = false | ||
| 674 | + | ||
| 675 | + self.kanDianOrAlbumChangeContentApi(contentId: model.contentId, title: model.title, isAlbum: isAblumVideo, activeId: model.pid) | ||
| 676 | +// self.refreshVodData(isAblumVideo: isAblumVideo) | ||
| 508 | } | 677 | } |
| 509 | return cell | 678 | return cell |
| 510 | }else{ | 679 | }else{ |
| @@ -517,12 +686,18 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa | @@ -517,12 +686,18 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa | ||
| 517 | let cell = CNLiveVodAlbumListCell() | 686 | let cell = CNLiveVodAlbumListCell() |
| 518 | return cell | 687 | return cell |
| 519 | } | 688 | } |
| 689 | + cell.currSeleIdx = self.albumIndex | ||
| 520 | cell.vodAlbumListBaseModel = vodAlbumListBaseModel | 690 | cell.vodAlbumListBaseModel = vodAlbumListBaseModel |
| 521 | 691 | ||
| 522 | - cell.selectBlock = {[weak self] vodModel, index in | 692 | + cell.selectBlock = {[weak self] vodModel, index ,albumListArr in |
| 523 | guard let self = self else { return } | 693 | guard let self = self else { return } |
| 524 | self.contentId = vodModel.contentId | 694 | self.contentId = vodModel.contentId |
| 525 | - self.changeContentApi(vodModel: vodModel) | 695 | + self.albumListArr = albumListArr |
| 696 | + self.albumIndex = index | ||
| 697 | + self.kanDianIndex = -1 | ||
| 698 | + self.isPlayAblumOrKandian = true | ||
| 699 | + self.kanDianOrAlbumChangeContentApi(contentId: vodModel.contentId, title: vodModel.title, isAlbum: true, activeId: vodModel.activityId) | ||
| 700 | +// self.changeContentApi(vodModel: vodModel) | ||
| 526 | } | 701 | } |
| 527 | return cell | 702 | return cell |
| 528 | }else if let vodPlayShopModels = self.dataArray[indexPath.row] as? [CNLiveVodPlayShopModel]{ | 703 | }else if let vodPlayShopModels = self.dataArray[indexPath.row] as? [CNLiveVodPlayShopModel]{ |
| @@ -624,12 +799,20 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa | @@ -624,12 +799,20 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa | ||
| 624 | guard let self = self else { return } | 799 | guard let self = self else { return } |
| 625 | self.contentId = model.contentId | 800 | self.contentId = model.contentId |
| 626 | var isAblumVideo = false | 801 | var isAblumVideo = false |
| 627 | - if model.model == "1"{ | ||
| 628 | - isAblumVideo = false | ||
| 629 | - }else{ | 802 | +// let isAblumVideo = (model.album?.albumId.count ?? 0 > 0) ? true : false |
| 803 | + if model.album?.albumId.count ?? 0 > 0{ | ||
| 630 | isAblumVideo = true | 804 | isAblumVideo = true |
| 805 | + }else{ | ||
| 806 | + isAblumVideo = false | ||
| 631 | } | 807 | } |
| 632 | - self.refreshVodData(isAblumVideo: isAblumVideo) | 808 | +// if model.model == "1"{ |
| 809 | +// isAblumVideo = false | ||
| 810 | +// }else{ | ||
| 811 | +// isAblumVideo = true | ||
| 812 | +// } | ||
| 813 | + self.isPlayAblumOrKandian = false | ||
| 814 | + self.kanDianOrAlbumChangeContentApi(contentId: model.contentId, title: model.title, isAlbum: isAblumVideo, activeId: model.pid) | ||
| 815 | +// self.refreshVodData(isAblumVideo: isAblumVideo) | ||
| 633 | } | 816 | } |
| 634 | } | 817 | } |
| 635 | // MARK: - 简介cell点击事件 | 818 | // MARK: - 简介cell点击事件 |
metaCode/Classes/Main/HuBiLieHomePage/Util/CNLiveDownSlideTool.swift
| @@ -351,7 +351,89 @@ class CNLiveDownSlideTool:NSObject{ | @@ -351,7 +351,89 @@ class CNLiveDownSlideTool:NSObject{ | ||
| 351 | } | 351 | } |
| 352 | 352 | ||
| 353 | class func pushVodController(contentId:String,navigationVC:UINavigationController?,isAblumVideo:Bool){ | 353 | class func pushVodController(contentId:String,navigationVC:UINavigationController?,isAblumVideo:Bool){ |
| 354 | - showLoading(message: "") | 354 | +showLoading(message: "") |
| 355 | +var tempIsAblumVideo = isAblumVideo | ||
| 356 | +//获取play | ||
| 357 | +CNLiveDownSlideTool.getVodPlayApi(contentId: contentId){ result, status in | ||
| 358 | + if status == .success{ | ||
| 359 | + if let tempVodModel = result as? CNLiveVodPlayModel{ | ||
| 360 | + if tempVodModel.album?.albumId.count ?? 0 > 0{ | ||
| 361 | + //专辑 | ||
| 362 | + //获取专辑详情 | ||
| 363 | + CNLiveDownSlideTool.getVodAlbumMsgApi(contentId: tempVodModel.album!.albumId){ result, status in | ||
| 364 | + if status == .success{ | ||
| 365 | + if let vodModel = result as? CNLiveVodAlbumMsgModel{ | ||
| 366 | + //获取专辑列表 | ||
| 367 | + CNLiveHomePageViewModel.requstWithVodAlbumVideoList(aid: tempVodModel.album!.albumId){result, status in | ||
| 368 | + if let albumListBaseModel = result as? CNLiveVodAlbumListBaseModel{ | ||
| 369 | + var currVodModel:CNLiveVodAlbumListModel? | ||
| 370 | + for (idx,albumListModel) in albumListBaseModel.list.enumerated(){ | ||
| 371 | + albumListModel.vodAlbumMsgModel = vodModel | ||
| 372 | + if idx == vodModel.episodeLast{ | ||
| 373 | + currVodModel = | ||
| 374 | + albumListModel } | ||
| 375 | + } | ||
| 376 | + //拿最新播放集数的单集pid,再请求play | ||
| 377 | +// CNLiveDownSlideTool.getVodPlayApi(contentId: currVodModel?.contentId ?? ""){ result, status in | ||
| 378 | +// if status == .success{ | ||
| 379 | +// if let vodModel = result as? CNLiveVodPlayModel{ | ||
| 380 | + //获得点播url | ||
| 381 | + //获取301播放地址 | ||
| 382 | + CNLiveHomePageViewModel.shared.getVodVideoURL(contentId: tempVodModel.contentId) {result,status in //vodModel.contentId result, status in | ||
| 383 | + hiddenLoading() | ||
| 384 | + if status == .success{ | ||
| 385 | + let vc = CNLiveTVPlayerViewController() | ||
| 386 | + let url = result as! String | ||
| 387 | + vc.url = URL(string: url) | ||
| 388 | + vc.vodPlayModel = tempVodModel//vodModel | ||
| 389 | + vc.contentId = contentId | ||
| 390 | + vc.vodAlbumListBaseModel = albumListBaseModel | ||
| 391 | + navigationVC?.pushViewController(vc, animated: pushAnimated) | ||
| 392 | + }else{ | ||
| 393 | + | ||
| 394 | + } | ||
| 395 | +// } | ||
| 396 | +// | ||
| 397 | +// }else{ | ||
| 398 | +// | ||
| 399 | +// } | ||
| 400 | +// } | ||
| 401 | + } | ||
| 402 | + | ||
| 403 | + } | ||
| 404 | + } | ||
| 405 | + } | ||
| 406 | + } | ||
| 407 | + } | ||
| 408 | + }else{ | ||
| 409 | + //单集 | ||
| 410 | + //获得点播url | ||
| 411 | + //获取301播放地址 | ||
| 412 | + CNLiveHomePageViewModel.shared.getVodVideoURL(contentId: tempVodModel.contentId) { result, status in | ||
| 413 | + hiddenLoading() | ||
| 414 | + if status == .success{ | ||
| 415 | + let vc = CNLiveTVPlayerViewController() | ||
| 416 | + let url = result as! String | ||
| 417 | + vc.url = URL(string: url) | ||
| 418 | + vc.vodPlayModel = tempVodModel | ||
| 419 | + vc.contentId = contentId | ||
| 420 | + navigationVC?.pushViewController(vc, animated: pushAnimated) | ||
| 421 | + }else{ | ||
| 422 | + | ||
| 423 | + } | ||
| 424 | + } | ||
| 425 | + } | ||
| 426 | + }else{ | ||
| 427 | + | ||
| 428 | + } | ||
| 429 | + } | ||
| 430 | +} | ||
| 431 | + | ||
| 432 | + | ||
| 433 | + | ||
| 434 | + | ||
| 435 | + | ||
| 436 | + /* | ||
| 355 | if isAblumVideo{ | 437 | if isAblumVideo{ |
| 356 | //专辑 | 438 | //专辑 |
| 357 | //获取专辑详情 | 439 | //获取专辑详情 |
| @@ -431,6 +513,7 @@ class CNLiveDownSlideTool:NSObject{ | @@ -431,6 +513,7 @@ class CNLiveDownSlideTool:NSObject{ | ||
| 431 | } | 513 | } |
| 432 | 514 | ||
| 433 | } | 515 | } |
| 516 | + */ | ||
| 434 | } | 517 | } |
| 435 | 518 | ||
| 436 | //专辑详情 | 519 | //专辑详情 |
metaCode/Classes/Main/HuBiLieHomePage/View/VodDetail/CNLiveVodAlbumListCell.swift
| @@ -7,11 +7,10 @@ | @@ -7,11 +7,10 @@ | ||
| 7 | 7 | ||
| 8 | import Foundation | 8 | import Foundation |
| 9 | 9 | ||
| 10 | -typealias CNLiveVodAlbumListCellSelectBlock = (_ vodModel:CNLiveVodAlbumListModel,_ index:Int)->Void; | 10 | +typealias CNLiveVodAlbumListCellSelectBlock = (_ vodModel:CNLiveVodAlbumListModel,_ index:Int,_ albumListModels:NSMutableArray)->Void; |
| 11 | 11 | ||
| 12 | class CNLiveVodAlbumListCell:UITableViewCell, UICollectionViewDelegate, UICollectionViewDataSource{ | 12 | class CNLiveVodAlbumListCell:UITableViewCell, UICollectionViewDelegate, UICollectionViewDataSource{ |
| 13 | - | ||
| 14 | - var selectIdx:Int = 0 | 13 | + var currSeleIdx:Int = 0 |
| 15 | var selectBlock:CNLiveVodAlbumListCellSelectBlock? | 14 | var selectBlock:CNLiveVodAlbumListCellSelectBlock? |
| 16 | //实时热榜的列表 | 15 | //实时热榜的列表 |
| 17 | lazy var albumListArr: NSMutableArray = { | 16 | lazy var albumListArr: NSMutableArray = { |
| @@ -78,7 +77,7 @@ class CNLiveVodAlbumListCell:UITableViewCell, UICollectionViewDelegate, UICollec | @@ -78,7 +77,7 @@ class CNLiveVodAlbumListCell:UITableViewCell, UICollectionViewDelegate, UICollec | ||
| 78 | func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { | 77 | func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { |
| 79 | 78 | ||
| 80 | let cell = collectionView.dequeueReusableCell(withReuseIdentifier: kCNLiveVodAlbumListCollectionCellIdentifier, for: indexPath) as! CNLiveVodAlbumListCollectionCell | 79 | let cell = collectionView.dequeueReusableCell(withReuseIdentifier: kCNLiveVodAlbumListCollectionCellIdentifier, for: indexPath) as! CNLiveVodAlbumListCollectionCell |
| 81 | - if self.selectIdx == indexPath.row{ | 80 | + if self.currSeleIdx == indexPath.row{ |
| 82 | //当前cell选中 | 81 | //当前cell选中 |
| 83 | cell.isJiShuSelected = true | 82 | cell.isJiShuSelected = true |
| 84 | }else{ | 83 | }else{ |
| @@ -92,8 +91,8 @@ class CNLiveVodAlbumListCell:UITableViewCell, UICollectionViewDelegate, UICollec | @@ -92,8 +91,8 @@ class CNLiveVodAlbumListCell:UITableViewCell, UICollectionViewDelegate, UICollec | ||
| 92 | func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { | 91 | func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { |
| 93 | if let vodAlbumListModel = self.albumListArr[indexPath.row] as? CNLiveVodAlbumListModel{ | 92 | if let vodAlbumListModel = self.albumListArr[indexPath.row] as? CNLiveVodAlbumListModel{ |
| 94 | //点击某集,刷新页面 | 93 | //点击某集,刷新页面 |
| 95 | - self.selectBlock?(vodAlbumListModel, indexPath.row) | ||
| 96 | - self.selectIdx = indexPath.row | 94 | + self.selectBlock?(vodAlbumListModel, indexPath.row, self.albumListArr) |
| 95 | + self.currSeleIdx = indexPath.row | ||
| 97 | self.realHotCollectionView.reloadData() | 96 | self.realHotCollectionView.reloadData() |
| 98 | 97 | ||
| 99 | } | 98 | } |
metaCode/Classes/Main/HuBiLieHomePage/View/VodDetail/CNLiveVodTrailersCell.swift
| @@ -8,7 +8,7 @@ | @@ -8,7 +8,7 @@ | ||
| 8 | import Foundation | 8 | import Foundation |
| 9 | 9 | ||
| 10 | typealias CNLiveVodTrailersCellExpandBlock = (_ model:CNLiveVodPlayBlockListModel)->Void | 10 | typealias CNLiveVodTrailersCellExpandBlock = (_ model:CNLiveVodPlayBlockListModel)->Void |
| 11 | -typealias CNLiveVodTrailersCellSelectBlock = (_ model:CNLiveVodPlayBlockListListModel)->Void | 11 | +typealias CNLiveVodTrailersCellSelectBlock = (_ model:CNLiveVodPlayBlockListListModel,_ index:Int ,_ albumListArr: NSMutableArray)->Void |
| 12 | 12 | ||
| 13 | class CNLiveVodTrailersCell:UITableViewCell, UICollectionViewDelegate, UICollectionViewDataSource{ | 13 | class CNLiveVodTrailersCell:UITableViewCell, UICollectionViewDelegate, UICollectionViewDataSource{ |
| 14 | 14 | ||
| @@ -105,7 +105,8 @@ class CNLiveVodTrailersCell:UITableViewCell, UICollectionViewDelegate, UICollect | @@ -105,7 +105,8 @@ class CNLiveVodTrailersCell:UITableViewCell, UICollectionViewDelegate, UICollect | ||
| 105 | func setupNewUI(model:CNLiveVodPlayBlockListModel){ | 105 | func setupNewUI(model:CNLiveVodPlayBlockListModel){ |
| 106 | self.titleLabel.text = model.name | 106 | self.titleLabel.text = model.name |
| 107 | self.albumListArr = NSMutableArray(array: model.list) | 107 | self.albumListArr = NSMutableArray(array: model.list) |
| 108 | - self.realHotCollectionView.scrollToItem(at: IndexPath(item: 0, section: 0), at: .left, animated: false) | 108 | + var index = self.currSeleIdx >= 0 ? self.currSeleIdx : 0 |
| 109 | + self.realHotCollectionView.scrollToItem(at: IndexPath(item: index, section: 0), at: .left, animated: false) | ||
| 109 | self.realHotCollectionView.reloadData() | 110 | self.realHotCollectionView.reloadData() |
| 110 | 111 | ||
| 111 | } | 112 | } |
| @@ -135,7 +136,7 @@ class CNLiveVodTrailersCell:UITableViewCell, UICollectionViewDelegate, UICollect | @@ -135,7 +136,7 @@ class CNLiveVodTrailersCell:UITableViewCell, UICollectionViewDelegate, UICollect | ||
| 135 | if let vodAlbumListModel = self.albumListArr[indexPath.row] as? CNLiveVodPlayBlockListListModel{ | 136 | if let vodAlbumListModel = self.albumListArr[indexPath.row] as? CNLiveVodPlayBlockListListModel{ |
| 136 | self.currSeleIdx = indexPath.row | 137 | self.currSeleIdx = indexPath.row |
| 137 | //点击某集,刷新页面 | 138 | //点击某集,刷新页面 |
| 138 | - self.selectBlock?(vodAlbumListModel) | 139 | + self.selectBlock?(vodAlbumListModel,currSeleIdx,self.albumListArr) |
| 139 | self.realHotCollectionView.reloadData() | 140 | self.realHotCollectionView.reloadData() |
| 140 | } | 141 | } |
| 141 | } | 142 | } |