Commit b409e70ded0bfc65ce3c13b2f910190551af5aee

Authored by “张旭”
1 parent 36115f60

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

metaCode/Classes/Main/VideoPage/Controller/CNLiveShortVideoViewController.swift
... ... @@ -116,8 +116,11 @@ class CNLiveShortVideoViewController : CNLiveBaseViewController, UITableViewDele
116 116 self.isSelectable = false
117 117 self.currentIndex = currentIndex
118 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 134 override func viewDidAppear(_ animated: Bool) {
132 135 super.viewDidAppear(animated)
133 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 140 override func viewWillDisappear(_ animated: Bool) {
... ... @@ -161,6 +165,7 @@ class CNLiveShortVideoViewController : CNLiveBaseViewController, UITableViewDele
161 165 player.allowOrentitaionRotation = false
162 166 player.isWWANAutoPlay = true
163 167 player.playerDisapperaPercent = 1.0
  168 + player.scrollView?.isPagingEnabled = true
164 169 player.playerReadyToPlay = {[weak self] asset, assetURL in
165 170 guard let self = self else { return }
166 171 self.controlView.videoPlayer((self.player)!, currentTime: self.player.currentTime, totalTime: self.player.totalTime)
... ... @@ -239,15 +244,15 @@ class CNLiveShortVideoViewController : CNLiveBaseViewController, UITableViewDele
239 244 }
240 245  
241 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 248 guard let self = self else { return }
244 249 if respStatue == .success {
245 250 if self.pageNum == 1 {
246 251 self.dataArray.removeAllObjects()
247 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 257 let listArray = (result as! [Any]).first as! [CNLiveAlbumListModel]
253 258 self.dataArray.addObjects(from: listArray)
... ... @@ -261,11 +266,9 @@ class CNLiveShortVideoViewController : CNLiveBaseViewController, UITableViewDele
261 266 }
262 267 self.tableView.refreshControl?.endRefreshing()
263 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 272 let hasNextPage = (result as! [Any])[1] as! Bool
270 273 if listArray.count == 0 && urlArray.count == 0 {
271 274 if !hasNextPage {
... ... @@ -279,11 +282,15 @@ class CNLiveShortVideoViewController : CNLiveBaseViewController, UITableViewDele
279 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 294 } else {
288 295 if self.tableView.mj_footer != nil {
289 296 self.tableView.mj_footer?.endRefreshing()
... ...
metaCode/Classes/Other/AppDelegate.swift
... ... @@ -18,7 +18,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
18 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 23 // Override point for customization after application launch.
24 24 //tencentAppId wxAppId
... ...