Commit 88a8de2682ab05b0f731c3ccc9bffbcb41217d7e
1 parent
77b5b7a9
自动旋转
Showing
1 changed file
with
150 additions
and
136 deletions
metaCode/Classes/Main/HuBiLieHomePage/Controller/CNLiveTVPlayerViewController.swift
| @@ -252,18 +252,18 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa | @@ -252,18 +252,18 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa | ||
| 252 | func setupNewUI(model:CNLiveDownSlideContentsModel){ | 252 | func setupNewUI(model:CNLiveDownSlideContentsModel){ |
| 253 | 253 | ||
| 254 | } | 254 | } |
| 255 | + | ||
| 256 | + // MARK: - 播放相关 | ||
| 257 | + | ||
| 255 | func setupPlayer(){ | 258 | func setupPlayer(){ |
| 256 | let playerManager = ZFAVPlayerManager() | 259 | let playerManager = ZFAVPlayerManager() |
| 257 | playerManager.shouldAutoPlay = true | 260 | playerManager.shouldAutoPlay = true |
| 258 | -// playerManager.rate = 2 | ||
| 259 | 261 | ||
| 260 | player = ZFPlayerController(playerManager: playerManager, containerView: containerView) | 262 | player = ZFPlayerController(playerManager: playerManager, containerView: containerView) |
| 261 | player.pauseWhenAppResignActive = false | 263 | player.pauseWhenAppResignActive = false |
| 262 | player.controlView = controlView | 264 | player.controlView = controlView |
| 263 | //不跟随设备旋转 | 265 | //不跟随设备旋转 |
| 264 | - player.allowOrentitaionRotation = false | ||
| 265 | - | ||
| 266 | - // self.player.currentPlayerManager.rate = 0.5 //点击按钮加 | 266 | + player.allowOrentitaionRotation = true |
| 267 | 267 | ||
| 268 | self.player.orientationDidChanged = {[weak self] player,isFullScreen in | 268 | self.player.orientationDidChanged = {[weak self] player,isFullScreen in |
| 269 | guard let self = self else { return } | 269 | guard let self = self else { return } |
| @@ -273,14 +273,7 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa | @@ -273,14 +273,7 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa | ||
| 273 | self.player.playerDidToEnd = { | 273 | self.player.playerDidToEnd = { |
| 274 | [weak self] asset in | 274 | [weak self] asset in |
| 275 | guard let self = self else { return } | 275 | guard let self = self else { return } |
| 276 | - | ||
| 277 | - // if (!self.player.isLastAssetURL) { | ||
| 278 | - // [self.player playTheNext]; | ||
| 279 | - // NSString *title = [NSString stringWithFormat:@"视频标题%zd",self.player.currentPlayIndex]; | ||
| 280 | - // [self.controlView showTitle:title coverURLString:kVideoCover fullScreenMode:ZFFullScreenModeLandscape]; | ||
| 281 | - // } else { | ||
| 282 | - // [self.player stop]; | ||
| 283 | - // } | 276 | + self.playNextIfExist() |
| 284 | } | 277 | } |
| 285 | 278 | ||
| 286 | var urls = [URL]() | 279 | var urls = [URL]() |
| @@ -314,6 +307,150 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa | @@ -314,6 +307,150 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa | ||
| 314 | } | 307 | } |
| 315 | } | 308 | } |
| 316 | 309 | ||
| 310 | + func playNextIfExist(){ | ||
| 311 | + //当前播放的是 专辑列表 ,播专辑列表下一条 | ||
| 312 | + //当前播放的是 看点列表 ,播看点列表下一条 | ||
| 313 | + | ||
| 314 | + if self.isAblumVideo{ | ||
| 315 | + //播专辑列表下一条 | ||
| 316 | + | ||
| 317 | + }else{ | ||
| 318 | + // | ||
| 319 | + } | ||
| 320 | + // if (!self.player.isLastAssetURL) { | ||
| 321 | + // [self.player playTheNext]; | ||
| 322 | + // NSString *title = [NSString stringWithFormat:@"视频标题%zd",self.player.currentPlayIndex]; | ||
| 323 | + // [self.controlView showTitle:title coverURLString:kVideoCover fullScreenMode:ZFFullScreenModeLandscape]; | ||
| 324 | + // } else { | ||
| 325 | + // [self.player stop]; | ||
| 326 | + // } | ||
| 327 | + | ||
| 328 | + } | ||
| 329 | + //播放url更换title | ||
| 330 | + func playWithUrlAndTitle(url:String,title:String){ | ||
| 331 | + if self.isSeek{ | ||
| 332 | + }else{ | ||
| 333 | + self.controlView.gaoqingBgView.resetGaoqing() | ||
| 334 | + } | ||
| 335 | + self.isSeek = false | ||
| 336 | + self.player.currentPlayerManager.rate = 1.0 | ||
| 337 | + self.playTitle = title | ||
| 338 | + self.url = URL(string: url) | ||
| 339 | + var urls = [URL]() | ||
| 340 | + urls.append(self.url!) | ||
| 341 | + self.player.assetURLs = urls | ||
| 342 | + self.player.playTheIndex(0) | ||
| 343 | + self.controlView.showTitle(title, cover: UIImage.imageWithColor(color: .darkGray, size: CGSize(width: 50, height: 50)), fullScreenMode: .landscape) | ||
| 344 | + } | ||
| 345 | + func seekPlayerWithUrlAndTitle(url:String,title:String,seekTime:TimeInterval){ | ||
| 346 | + self.isSeek = true | ||
| 347 | + self.playWithUrlAndTitle(url: url, title: title) | ||
| 348 | + self.player.seek(toTime: seekTime) | ||
| 349 | + | ||
| 350 | + } | ||
| 351 | + | ||
| 352 | + //单集 更换contentId内容 play接口刷新看点和电商 | ||
| 353 | + func vodChangeContentApi(vodModel:CNLiveVodAlbumListModel){ | ||
| 354 | + //刷新url | ||
| 355 | + CNLiveHomePageViewModel.shared.getVodVideoURL(contentId: vodModel.activityId) {[weak self] result, status in | ||
| 356 | + guard let self = self else { return } | ||
| 357 | + if status == .success | ||
| 358 | + { | ||
| 359 | + if let url = result as? String{ | ||
| 360 | + self.playWithUrlAndTitle(url: url, title: vodModel.title) | ||
| 361 | + } | ||
| 362 | + }else{ | ||
| 363 | + | ||
| 364 | + } | ||
| 365 | + } | ||
| 366 | + | ||
| 367 | + | ||
| 368 | + //play接口刷新 看点和电商 | ||
| 369 | + CNLiveDownSlideTool.getVodPlayApi(contentId: vodModel.contentId) {[weak self] result, status in | ||
| 370 | + guard let self = self else { return } | ||
| 371 | + if status == .success{ | ||
| 372 | + if let vodPlayModel = result as? CNLiveVodPlayModel{ | ||
| 373 | + self.vodPlayModel = vodPlayModel | ||
| 374 | + self.configDataArray() | ||
| 375 | + self.tableView.reloadData() | ||
| 376 | + }else{ | ||
| 377 | + | ||
| 378 | + } | ||
| 379 | + }else{ | ||
| 380 | + | ||
| 381 | + } | ||
| 382 | + } | ||
| 383 | + | ||
| 384 | + } | ||
| 385 | + func destroyPlayer(){ | ||
| 386 | + self.player.stop() | ||
| 387 | + } | ||
| 388 | + | ||
| 389 | + // MARK: -专辑列表切换某集 ,刷新看点和电商 | ||
| 390 | + func changeContentApi(vodModel:CNLiveVodAlbumListModel){ | ||
| 391 | + | ||
| 392 | + //刷新url | ||
| 393 | + CNLiveHomePageViewModel.shared.getVodVideoURL(contentId: vodModel.activityId) {[weak self] result, status in | ||
| 394 | + guard let self = self else { return } | ||
| 395 | + if status == .success | ||
| 396 | + { | ||
| 397 | + if let url = result as? String{ | ||
| 398 | + self.playWithUrlAndTitle(url: url, title: vodModel.title) | ||
| 399 | + } | ||
| 400 | + }else{ | ||
| 401 | + | ||
| 402 | + } | ||
| 403 | + } | ||
| 404 | + | ||
| 405 | + | ||
| 406 | + //play接口刷新 看点和电商 | ||
| 407 | + CNLiveDownSlideTool.getVodPlayApi(contentId: vodModel.contentId) {[weak self] result, status in | ||
| 408 | + guard let self = self else { return } | ||
| 409 | + if status == .success{ | ||
| 410 | + if let vodPlayModel = result as? CNLiveVodPlayModel{ | ||
| 411 | + self.vodPlayModel = vodPlayModel | ||
| 412 | + self.configDataArray() | ||
| 413 | + self.tableView.reloadData() | ||
| 414 | + }else{ | ||
| 415 | + | ||
| 416 | + } | ||
| 417 | + }else{ | ||
| 418 | + | ||
| 419 | + } | ||
| 420 | + } | ||
| 421 | + | ||
| 422 | + } | ||
| 423 | + // MARK: - 刷新 整个页面 | ||
| 424 | + func refreshVodData(isAblumVideo:Bool){ | ||
| 425 | + CNLiveDownSlideTool.getVodData(contentId: self.contentId, isAblumVideo: isAblumVideo) {[weak self] vodPlayModel, contentId,url, result, status in | ||
| 426 | + if status == .success{ | ||
| 427 | + self!.vodPlayModel = vodPlayModel | ||
| 428 | + self!.contentId = contentId | ||
| 429 | + if let vodAlbumListBaseModel = result{ | ||
| 430 | + self!.vodAlbumListBaseModel = vodAlbumListBaseModel | ||
| 431 | + } | ||
| 432 | + self!.url = URL(string: url) | ||
| 433 | + self!.configDataArray() | ||
| 434 | + self!.tableView.mj_header?.endRefreshing() | ||
| 435 | + self!.tableView.reloadData() | ||
| 436 | + var title = "" | ||
| 437 | + for (_,mdl) in vodPlayModel.blockList.enumerated(){ | ||
| 438 | + if mdl.type == "5" && mdl.list.count > 0 {//点播详情数据 | ||
| 439 | + //CNLiveVodPlayBlockListListModel | ||
| 440 | + if let playMdl = mdl.list.first as? CNLiveVodPlayBlockListListModel{ | ||
| 441 | + title = playMdl.title | ||
| 442 | + } | ||
| 443 | + } | ||
| 444 | + } | ||
| 445 | + self!.playWithUrlAndTitle(url: url, title: title) | ||
| 446 | + }else{ | ||
| 447 | + | ||
| 448 | + } | ||
| 449 | + } | ||
| 450 | + } | ||
| 451 | + | ||
| 452 | + | ||
| 453 | + | ||
| 317 | // MARK: - UITableViewDelegate | 454 | // MARK: - UITableViewDelegate |
| 318 | func numberOfSections(in tableView: UITableView) -> Int { | 455 | func numberOfSections(in tableView: UITableView) -> Int { |
| 319 | return 1 | 456 | return 1 |
| @@ -435,99 +572,7 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa | @@ -435,99 +572,7 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa | ||
| 435 | self!.refreshVodData(isAblumVideo: self!.isAblumVideo) | 572 | self!.refreshVodData(isAblumVideo: self!.isAblumVideo) |
| 436 | }) | 573 | }) |
| 437 | } | 574 | } |
| 438 | - | ||
| 439 | - //单集 更换contentId内容 play接口刷新看点和电商 | ||
| 440 | - func vodChangeContentApi(vodModel:CNLiveVodAlbumListModel){ | ||
| 441 | - //刷新url | ||
| 442 | - CNLiveHomePageViewModel.shared.getVodVideoURL(contentId: vodModel.activityId) {[weak self] result, status in | ||
| 443 | - guard let self = self else { return } | ||
| 444 | - if status == .success | ||
| 445 | - { | ||
| 446 | - if let url = result as? String{ | ||
| 447 | - self.playWithUrlAndTitle(url: url, title: vodModel.title) | ||
| 448 | - } | ||
| 449 | - }else{ | ||
| 450 | - | ||
| 451 | - } | ||
| 452 | - } | ||
| 453 | - | ||
| 454 | - | ||
| 455 | - //play接口刷新 看点和电商 | ||
| 456 | - CNLiveDownSlideTool.getVodPlayApi(contentId: vodModel.contentId) {[weak self] result, status in | ||
| 457 | - guard let self = self else { return } | ||
| 458 | - if status == .success{ | ||
| 459 | - if let vodPlayModel = result as? CNLiveVodPlayModel{ | ||
| 460 | - self.vodPlayModel = vodPlayModel | ||
| 461 | - self.configDataArray() | ||
| 462 | - self.tableView.reloadData() | ||
| 463 | - }else{ | ||
| 464 | - | ||
| 465 | - } | ||
| 466 | - }else{ | ||
| 467 | - | ||
| 468 | - } | ||
| 469 | - } | ||
| 470 | - | ||
| 471 | - } | ||
| 472 | - | ||
| 473 | - //专辑 更换contentId内容 play接口刷新看点和电商 | ||
| 474 | - func changeContentApi(vodModel:CNLiveVodAlbumListModel){ | ||
| 475 | - | ||
| 476 | - //刷新url | ||
| 477 | - CNLiveHomePageViewModel.shared.getVodVideoURL(contentId: vodModel.activityId) {[weak self] result, status in | ||
| 478 | - guard let self = self else { return } | ||
| 479 | - if status == .success | ||
| 480 | - { | ||
| 481 | - if let url = result as? String{ | ||
| 482 | - self.playWithUrlAndTitle(url: url, title: vodModel.title) | ||
| 483 | - } | ||
| 484 | - }else{ | ||
| 485 | - | ||
| 486 | - } | ||
| 487 | - } | ||
| 488 | - | ||
| 489 | - | ||
| 490 | - //play接口刷新 看点和电商 | ||
| 491 | - CNLiveDownSlideTool.getVodPlayApi(contentId: vodModel.contentId) {[weak self] result, status in | ||
| 492 | - guard let self = self else { return } | ||
| 493 | - if status == .success{ | ||
| 494 | - if let vodPlayModel = result as? CNLiveVodPlayModel{ | ||
| 495 | - self.vodPlayModel = vodPlayModel | ||
| 496 | - self.configDataArray() | ||
| 497 | - self.tableView.reloadData() | ||
| 498 | - }else{ | ||
| 499 | - | ||
| 500 | - } | ||
| 501 | - }else{ | ||
| 502 | - | ||
| 503 | - } | ||
| 504 | - } | ||
| 505 | - | ||
| 506 | - } | ||
| 507 | - | ||
| 508 | - //播放url更换title | ||
| 509 | - func playWithUrlAndTitle(url:String,title:String){ | ||
| 510 | - if self.isSeek{ | ||
| 511 | - }else{ | ||
| 512 | - self.controlView.gaoqingBgView.resetGaoqing() | ||
| 513 | - } | ||
| 514 | - self.isSeek = false | ||
| 515 | - self.player.currentPlayerManager.rate = 1.0 | ||
| 516 | - self.playTitle = title | ||
| 517 | - self.url = URL(string: url) | ||
| 518 | - var urls = [URL]() | ||
| 519 | - urls.append(self.url!) | ||
| 520 | - self.player.assetURLs = urls | ||
| 521 | - self.player.playTheIndex(0) | ||
| 522 | - self.controlView.showTitle(title, cover: UIImage.imageWithColor(color: .darkGray, size: CGSize(width: 50, height: 50)), fullScreenMode: .landscape) | ||
| 523 | - } | ||
| 524 | - func seekPlayerWithUrlAndTitle(url:String,title:String,seekTime:TimeInterval){ | ||
| 525 | - self.isSeek = true | ||
| 526 | - self.playWithUrlAndTitle(url: url, title: title) | ||
| 527 | - self.player.seek(toTime: seekTime) | ||
| 528 | - | ||
| 529 | - } | ||
| 530 | - | 575 | + |
| 531 | override var preferredStatusBarStyle: UIStatusBarStyle{ | 576 | override var preferredStatusBarStyle: UIStatusBarStyle{ |
| 532 | return .lightContent | 577 | return .lightContent |
| 533 | } | 578 | } |
| @@ -704,37 +749,6 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa | @@ -704,37 +749,6 @@ class CNLiveTVPlayerViewController:UIViewController, UITableViewDataSource, UITa | ||
| 704 | } | 749 | } |
| 705 | } | 750 | } |
| 706 | 751 | ||
| 707 | - func destroyPlayer(){ | ||
| 708 | - self.player.stop() | ||
| 709 | - } | ||
| 710 | - | ||
| 711 | - func refreshVodData(isAblumVideo:Bool){ | ||
| 712 | - CNLiveDownSlideTool.getVodData(contentId: self.contentId, isAblumVideo: isAblumVideo) {[weak self] vodPlayModel, contentId,url, result, status in | ||
| 713 | - if status == .success{ | ||
| 714 | - self!.vodPlayModel = vodPlayModel | ||
| 715 | - self!.contentId = contentId | ||
| 716 | - if let vodAlbumListBaseModel = result{ | ||
| 717 | - self!.vodAlbumListBaseModel = vodAlbumListBaseModel | ||
| 718 | - } | ||
| 719 | - self!.url = URL(string: url) | ||
| 720 | - self!.configDataArray() | ||
| 721 | - self!.tableView.mj_header?.endRefreshing() | ||
| 722 | - self!.tableView.reloadData() | ||
| 723 | - var title = "" | ||
| 724 | - for (_,mdl) in vodPlayModel.blockList.enumerated(){ | ||
| 725 | - if mdl.type == "5" && mdl.list.count > 0 {//点播详情数据 | ||
| 726 | - //CNLiveVodPlayBlockListListModel | ||
| 727 | - if let playMdl = mdl.list.first as? CNLiveVodPlayBlockListListModel{ | ||
| 728 | - title = playMdl.title | ||
| 729 | - } | ||
| 730 | - } | ||
| 731 | - } | ||
| 732 | - self!.playWithUrlAndTitle(url: url, title: title) | ||
| 733 | - }else{ | ||
| 734 | - | ||
| 735 | - } | ||
| 736 | - } | ||
| 737 | - } | ||
| 738 | // MARK: - 点播play接口 | 752 | // MARK: - 点播play接口 |
| 739 | /* | 753 | /* |
| 740 | func requestGetVodPlayApi(contentId:String){ | 754 | func requestGetVodPlayApi(contentId:String){ |