Commit b409e70ded0bfc65ce3c13b2f910190551af5aee

Authored by “张旭”
1 parent 36115f60

记录上次播放的是哪集直接播放

metaCode/Classes/Main/VideoPage/Controller/CNLiveShortVideoViewController.swift
@@ -116,8 +116,11 @@ class CNLiveShortVideoViewController : CNLiveBaseViewController, UITableViewDele @@ -116,8 +116,11 @@ class CNLiveShortVideoViewController : CNLiveBaseViewController, UITableViewDele
116 self.isSelectable = false 116 self.isSelectable = false
117 self.currentIndex = currentIndex 117 self.currentIndex = currentIndex
118 super.init(nibName:nil, bundle:nil) 118 super.init(nibName:nil, bundle:nil)
119 - let page = self.roundUpToNearestTen(currentIndex)  
120 - self.pageNum = page/10 119 + var page = (self.roundUpToNearestTen(currentIndex))/10
  120 + if page == 0 {
  121 + page = 1
  122 + }
  123 + self.pageNum = page
121 124
122 } 125 }
123 126
@@ -131,6 +134,7 @@ class CNLiveShortVideoViewController : CNLiveBaseViewController, UITableViewDele @@ -131,6 +134,7 @@ class CNLiveShortVideoViewController : CNLiveBaseViewController, UITableViewDele
131 override func viewDidAppear(_ animated: Bool) { 134 override func viewDidAppear(_ animated: Bool) {
132 super.viewDidAppear(animated) 135 super.viewDidAppear(animated)
133 self.player.currentPlayerManager.play() 136 self.player.currentPlayerManager.play()
  137 + self.player.scrollView?.setContentOffset(CGPoint(x: 0, y:CGFloat(self.currentIndex!)*KSreenHeight), animated: true)//校正偏移量
134 } 138 }
135 139
136 override func viewWillDisappear(_ animated: Bool) { 140 override func viewWillDisappear(_ animated: Bool) {
@@ -161,6 +165,7 @@ class CNLiveShortVideoViewController : CNLiveBaseViewController, UITableViewDele @@ -161,6 +165,7 @@ class CNLiveShortVideoViewController : CNLiveBaseViewController, UITableViewDele
161 player.allowOrentitaionRotation = false 165 player.allowOrentitaionRotation = false
162 player.isWWANAutoPlay = true 166 player.isWWANAutoPlay = true
163 player.playerDisapperaPercent = 1.0 167 player.playerDisapperaPercent = 1.0
  168 + player.scrollView?.isPagingEnabled = true
164 player.playerReadyToPlay = {[weak self] asset, assetURL in 169 player.playerReadyToPlay = {[weak self] asset, assetURL in
165 guard let self = self else { return } 170 guard let self = self else { return }
166 self.controlView.videoPlayer((self.player)!, currentTime: self.player.currentTime, totalTime: self.player.totalTime) 171 self.controlView.videoPlayer((self.player)!, currentTime: self.player.currentTime, totalTime: self.player.totalTime)
@@ -239,15 +244,15 @@ class CNLiveShortVideoViewController : CNLiveBaseViewController, UITableViewDele @@ -239,15 +244,15 @@ class CNLiveShortVideoViewController : CNLiveBaseViewController, UITableViewDele
239 } 244 }
240 245
241 func requestData(resultBlock: @escaping (_ noMore: Bool) -> Void) { 246 func requestData(resultBlock: @escaping (_ noMore: Bool) -> Void) {
242 - CNLiveShortVideoViewModel.requstWithShortVideo(aid: self.aid, page: self.pageNum) { [weak self] result, respStatue in 247 + CNLiveShortVideoViewModel.requstWithShortVideo(aid: self.aid, page: self.pageNum, pageSize: "10") { [weak self] result, respStatue in
243 guard let self = self else { return } 248 guard let self = self else { return }
244 if respStatue == .success { 249 if respStatue == .success {
245 if self.pageNum == 1 { 250 if self.pageNum == 1 {
246 self.dataArray.removeAllObjects() 251 self.dataArray.removeAllObjects()
247 self.dataURLArray.removeAllObjects() 252 self.dataURLArray.removeAllObjects()
248 - if self.currentIndex == 0 {  
249 - self.tableView.setContentOffset(CGPoint.zero, animated: false)  
250 - } 253 +// if self.currentIndex == 0 {
  254 +// self.tableView.setContentOffset(CGPoint.zero, animated: false)
  255 +// }
251 } 256 }
252 let listArray = (result as! [Any]).first as! [CNLiveAlbumListModel] 257 let listArray = (result as! [Any]).first as! [CNLiveAlbumListModel]
253 self.dataArray.addObjects(from: listArray) 258 self.dataArray.addObjects(from: listArray)
@@ -261,11 +266,9 @@ class CNLiveShortVideoViewController : CNLiveBaseViewController, UITableViewDele @@ -261,11 +266,9 @@ class CNLiveShortVideoViewController : CNLiveBaseViewController, UITableViewDele
261 } 266 }
262 self.tableView.refreshControl?.endRefreshing() 267 self.tableView.refreshControl?.endRefreshing()
263 self.tableView.reloadData() 268 self.tableView.reloadData()
264 - if self.pageNum == 1 {  
265 - DispatchQueue.main.async {  
266 - self.tableView.contentOffset = CGPoint.zero  
267 - }  
268 - } 269 +// if self.pageNum == 1 {
  270 +// self.tableView.contentOffset = CGPoint.zero
  271 +// }
269 let hasNextPage = (result as! [Any])[1] as! Bool 272 let hasNextPage = (result as! [Any])[1] as! Bool
270 if listArray.count == 0 && urlArray.count == 0 { 273 if listArray.count == 0 && urlArray.count == 0 {
271 if !hasNextPage { 274 if !hasNextPage {
@@ -279,11 +282,15 @@ class CNLiveShortVideoViewController : CNLiveBaseViewController, UITableViewDele @@ -279,11 +282,15 @@ class CNLiveShortVideoViewController : CNLiveBaseViewController, UITableViewDele
279 self.tableView.mj_footer = footerRefreshView 282 self.tableView.mj_footer = footerRefreshView
280 } 283 }
281 } 284 }
282 - if self.pageNum == 1 {  
283 - self.playTheIndex(index: self.currentIndex)  
284 - } else {  
285 - self.playTheIndex(index: (self.pageNum - 1)*10) 285 +
  286 + let model = listArray.first?.albumMsgModel
  287 + let toIndex = (model?.episodeLast ?? 1)-1 <= 0 ? 0 : (model?.episodeLast ?? 1)-1
  288 + var page = (self.roundUpToNearestTen(toIndex))/10
  289 + if page == 0 {
  290 + page = 1
286 } 291 }
  292 + self.pageNum = page
  293 + self.playTheIndex(index: toIndex)
287 } else { 294 } else {
288 if self.tableView.mj_footer != nil { 295 if self.tableView.mj_footer != nil {
289 self.tableView.mj_footer?.endRefreshing() 296 self.tableView.mj_footer?.endRefreshing()
metaCode/Classes/Other/AppDelegate.swift
@@ -18,7 +18,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { @@ -18,7 +18,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
18 var window: UIWindow? 18 var window: UIWindow?
19 19
20 20
21 - func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 21 + func application(_ appUITableViewRowDatalication: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
22 22
23 // Override point for customization after application launch. 23 // Override point for customization after application launch.
24 //tencentAppId wxAppId 24 //tencentAppId wxAppId