YOUPAIZYSeeVideosVC.m 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566
  1. //
  2. // YOUPAIZYSeeVideosVC.m
  3. // VQU
  4. //
  5. // Created by Elaine on 2020/11/17.
  6. // Copyright © 2020 leo. All rights reserved.
  7. //
  8. #import "YOUPAIZYSeeVideosVC.h"
  9. #import "YOUPAIZYVideoModel.h"
  10. #import "YOUPAIEyeCatchingWaiterCell.h"
  11. #import "ZFPlayer.h"
  12. #import "ZFAVPlayerManager.h"
  13. #import "YOUPAIZFDouYinControlView.h"
  14. #import "YOUPAILZUserShowVC.h"
  15. #import "YOUPAILCIMSessionVC.h"
  16. #import "YOUPAILZCommonGiftView.h"
  17. #import "UIViewController+TFPresent.h"
  18. #import "YOUPAIXRWalletVC.h"
  19. @interface YOUPAIZYSeeVideosVC ()<UITableViewDelegate, UITableViewDataSource,EyeCatchingWaiterCellDelegate>
  20. @property (nonatomic, strong) UITableView *youpaiptableView;
  21. @property (nonatomic, strong) ZFPlayerController *youpaipzFplayer;
  22. @property (nonatomic, strong) YOUPAIZFDouYinControlView *youpaipcontrolView;
  23. @property(nonatomic,assign)NSInteger youpaipcurrentPage;//代表当前页码
  24. @property(nonatomic,assign)NSInteger youpaiptotalPage;//总页码
  25. @property (nonatomic,assign)BOOL youpaipisLeavePage;// 是否离开
  26. @end
  27. @implementation YOUPAIZYSeeVideosVC
  28. - (UIStatusBarStyle)preferredStatusBarStyle{
  29. return UIStatusBarStyleLightContent;
  30. }
  31. -(void)viewWillAppear:(BOOL)animated
  32. {
  33. [super viewWillAppear:animated];
  34. // self.navigationController.navigationBar.translucent = YES;
  35. // [self.navigationController.navigationBar setBackgroundImage:[UIImage imageWithColor:HexColorFromRGBA(0xffffff, 0) size:CGSizeMake(KScreenWidth, NavBarHeight)] forBarMetrics:(UIBarMetricsDefault)];
  36. self.youpaipisLeavePage = NO;
  37. [self.youpaipzFplayer.currentPlayerManager play];
  38. [self.youpaipcontrolView youpaifresetControlView];
  39. self.navigationController.navigationBar.translucent = YES;
  40. UIImage *img = [UIImage imageWithColor:[LCBkgColor colorWithAlphaComponent:0.0f] size:CGSizeMake(KScreenWidth, NavBarHeight)];
  41. [self.navigationController.navigationBar setBackgroundImage:img forBarMetrics:(UIBarMetricsDefault)];
  42. [self.navigationController.navigationBar setBackgroundColor:[LCBkgColor colorWithAlphaComponent:0.0f]];
  43. if (@available(iOS 15.0, *)) {
  44. [self.navigationController.navigationBar.scrollEdgeAppearance setBackgroundColor:[LCBkgColor colorWithAlphaComponent:0.0f]];
  45. [self.navigationController.navigationBar.scrollEdgeAppearance setBackgroundImage:img];
  46. [self.navigationController.navigationBar.standardAppearance setBackgroundColor:[LCBkgColor colorWithAlphaComponent:0.0f]];
  47. [self.navigationController.navigationBar.standardAppearance setBackgroundImage:img];
  48. }
  49. }
  50. -(void)viewWillDisappear:(BOOL)animated
  51. {
  52. [super viewWillDisappear:animated];
  53. // [self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
  54. // self.navigationController.navigationBar.translucent = NO;
  55. self.youpaipisLeavePage = YES;
  56. [self.youpaipzFplayer.currentPlayerManager pause];
  57. UIImage *img = [UIImage imageWithColor:LCNavColor size:CGSizeMake(KScreenWidth, NavBarHeight)];
  58. [self.navigationController.navigationBar setBackgroundImage:img forBarMetrics:UIBarMetricsDefault];
  59. [self.navigationController.navigationBar setBackgroundColor:LCNavColor];
  60. if (@available(iOS 15.0, *)) {
  61. [self.navigationController.navigationBar.scrollEdgeAppearance setBackgroundColor:LCNavColor];
  62. [self.navigationController.navigationBar.scrollEdgeAppearance setBackgroundImage:img];
  63. [self.navigationController.navigationBar.standardAppearance setBackgroundColor:LCNavColor];
  64. [self.navigationController.navigationBar.standardAppearance setBackgroundImage:img];
  65. }
  66. self.navigationController.navigationBar.translucent = NO;
  67. }
  68. - (void)viewDidLoad {
  69. [super viewDidLoad];
  70. [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(youpaifrefreshSeeVideoVCGuanZhuNotic:) name:@"refreshSeeVideoVCGuanZhu" object:nil];;
  71. [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(youpaifrefreshSeeVideoVCGuanZhuNotic:) name:@"ChangeFollowState" object:nil];;
  72. self.navigationItem.leftBarButtonItem = [UIBarButtonItem itemWithTarget:self action:@selector(youpaifbackClick) image:[UIImage imageNamed:@"vqu_images_navigation_back_black"]];
  73. if([self.youpaipuserId isEqualToString:[LCSaveModel getUserModel].youpaipuserinfo.youpaipuser_id]){
  74. self.navigationItem.rightBarButtonItem = [UIBarButtonItem itemWithTarget:self action:@selector(youpaifmoreClick) image:[UIImage imageNamed:@"vqu_images_more2"]];
  75. }
  76. [self youpaifinitTableView];
  77. [self.youpaiptableView scrollToRowAtIndexPath:self.youpaipindexPath atScrollPosition:UITableViewScrollPositionTop animated:YES];
  78. self.youpaipzFplayer.assetURLs = self.youpaipmp4UrlArray;
  79. [self youpaifplayTheVideoAtIndexPath:self.youpaipindexPath];
  80. [self youpaifplayScrollVideo:NO is_follow:3];
  81. }
  82. -(void)youpaifplayScrollVideo:(BOOL)changeStatus is_follow:(NSInteger)is_follow{
  83. @weakify(self);
  84. self.youpaipzFplayer.zf_playerShouldPlayInScrollView = ^(NSIndexPath * _Nonnull indexPath) {
  85. NSLog(@"%@",indexPath);
  86. @strongify(self);
  87. YOUPAIEyeCatchingWaiterCell *cell = (YOUPAIEyeCatchingWaiterCell*)[self.youpaiptableView cellForRowAtIndexPath:indexPath];
  88. if (changeStatus) {
  89. cell.model.youpaipis_follow = is_follow;
  90. }else{
  91. }
  92. for(UIView*firstView in cell.subviews) {
  93. for(UIView*lastView in firstView.subviews) {
  94. if(lastView.tag == 100) {
  95. for(UIView*playerPresentView in lastView.subviews) {
  96. playerPresentView.backgroundColor= [UIColor clearColor];
  97. }
  98. }
  99. }
  100. }
  101. };
  102. }
  103. -(void)youpaifrefreshSeeVideoVCGuanZhuNotic:(NSNotification*)notification{
  104. NSDictionary *dict = [notification userInfo];
  105. NSString *idStr = dict[@"follow_uid"];
  106. NSInteger isfollow = [dict[@"is_follow"] intValue];
  107. NSArray *arr = self.youpaipvideoDataArray;
  108. if (arr.count>0) {
  109. NSIndexPath *index;
  110. NSMutableArray *arrM = [NSMutableArray new];
  111. for (int i = 0; i<arr.count; i++) {
  112. YOUPAIZYVideoModel *model = arr[i];
  113. if ([model.youpaipuser_id isEqualToString:idStr]) {
  114. model.youpaipis_follow = isfollow;
  115. index = [NSIndexPath indexPathForRow:i inSection:0];
  116. [arrM addObject:index];
  117. }
  118. }
  119. [UIView performWithoutAnimation:^{
  120. [self.youpaiptableView reloadRowsAtIndexPaths:arrM withRowAnimation:UITableViewRowAnimationFade];
  121. }];
  122. }
  123. }
  124. -(void)dealloc{
  125. [[NSNotificationCenter defaultCenter]removeObserver:self];
  126. }
  127. - (void)youpaifbackClick{
  128. [self.navigationController popViewControllerAnimated:YES];
  129. }
  130. - (void)youpaifmoreClick{
  131. ZCAlertAction*action = [ZCAlertAction actionWithTitle:@"删除" andblock:^{//举报
  132. if (self.youpaipvideoDataArray.count == 0) {
  133. return;
  134. }
  135. NSInteger row = self.youpaipindexPath.row;
  136. NSLog(@"row ===%ld",row);
  137. YOUPAIZYVideoModel *model = self->_youpaipvideoDataArray[row];
  138. [LCHttpHelper requestWithURLString:TrendsDelete parameters:@{@"vt_id":model.youpaipvideoId} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  139. NSDictionary* dict = (NSDictionary*)responseObject;
  140. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  141. if (code==0) {//成功
  142. // [self.videoDataArray removeObjectAtIndex:row];
  143. // [self.mp4UrlArray removeObjectAtIndex:row];
  144. // [self.tableView reloadData];
  145. [self.youpaiptableView.mj_header beginRefreshing];
  146. }
  147. } failure:^(NSError *error) {
  148. }];
  149. }];;
  150. ZCAlertSheetView* alertSheet = [[ZCAlertSheetView alloc]initWithTitle:nil andShowCancelButton:YES andAction:@[action]];
  151. alertSheet.alertWindow.hidden = NO;
  152. [alertSheet show];
  153. }
  154. - (void)youpaifloadNewData{
  155. self.youpaiptableView.mj_footer.hidden = YES;
  156. [self.youpaiptableView.mj_footer endRefreshing];//先结束上拉,假如有的话
  157. [self.youpaiptableView.mj_footer endRefreshingWithNoMoreData];
  158. self.youpaiptableView.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingTarget:self refreshingAction:@selector(youpaifloadMoreData)];
  159. self.youpaipcurrentPage = 1;
  160. [LCHttpHelper requestWithURLString:TrendsLists parameters:@{@"page":@(self.youpaipcurrentPage),@"user_id":self.youpaipuserId} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  161. NSDictionary* dict = (NSDictionary*)responseObject;
  162. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  163. if (code==0) {//成功
  164. [self.youpaipvideoDataArray removeAllObjects];
  165. [self.youpaipmp4UrlArray removeAllObjects];
  166. self.youpaipvideoDataArray = [YOUPAIZYVideoModel mj_objectArrayWithKeyValuesArray:[[dict objectForKey:@"data"] objectForKey:@"list"]];
  167. self.youpaiptotalPage = [[[dict objectForKey:@"data"] objectForKey:@"total_page"] integerValue];
  168. NSInteger currentPage = [[[dict objectForKey:@"data"] objectForKey:@"page"] integerValue];
  169. self.youpaipcurrentPage = currentPage;
  170. for (YOUPAIZYVideoModel *model in self.youpaipvideoDataArray) {
  171. [self.youpaipmp4UrlArray addObject:[NSURL URLWithString:model.youpaipfile_url]];
  172. }
  173. NSLog(@"%@",self.youpaipmp4UrlArray);
  174. self.youpaipzFplayer.assetURLs = self.youpaipmp4UrlArray;
  175. [self.youpaiptableView reloadData];
  176. [self.youpaipzFplayer.currentPlayerManager pause];
  177. if (self.youpaipvideoDataArray.count != 0) {
  178. NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0];
  179. [self youpaifplayTheVideoAtIndexPath:indexPath];
  180. if (self.youpaipisLeavePage) {
  181. [self.youpaipzFplayer.currentPlayerManager pause];
  182. }
  183. }
  184. // __weak typeof(self) weakSelf = self;
  185. // [self.zFplayer zf_filterShouldPlayCellWhileScrolled:^(NSIndexPath *indexPath) {
  186. // [weakSelf youpaifplayTheVideoAtIndexPath:indexPath];
  187. // NSLog(@"%@",indexPath);
  188. // }];
  189. if (currentPage>=self.youpaiptotalPage) {
  190. [self.youpaiptableView.mj_footer endRefreshingWithNoMoreData];
  191. self.youpaiptableView.mj_footer.hidden = YES;
  192. }
  193. [self.youpaiptableView.mj_header endRefreshing];
  194. }else{
  195. [self.youpaiptableView.mj_header endRefreshing];
  196. }
  197. } failure:^(NSError *error) {
  198. [self.youpaiptableView.mj_header endRefreshing];
  199. }];
  200. }
  201. - (void)youpaifloadMoreData{
  202. //先结束下拉 假如有的话
  203. [self.youpaiptableView.mj_header endRefreshing];
  204. [LCHttpHelper requestWithURLString:TrendsLists parameters:@{@"page":@(self.youpaipcurrentPage+1),@"user_id":self.youpaipuserId} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  205. NSDictionary* dict = (NSDictionary*)responseObject;
  206. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  207. if (code==0) {//成功
  208. NSInteger count = self.youpaipvideoDataArray.count;
  209. NSMutableArray* modelArray = [YOUPAIZYVideoModel mj_objectArrayWithKeyValuesArray:[[dict objectForKey:@"data"]objectForKey:@"list"]];
  210. [self.youpaipvideoDataArray addObjectsFromArray:modelArray];
  211. self.youpaiptotalPage = [[[dict objectForKey:@"data"] objectForKey:@"total_page"] integerValue];
  212. NSInteger currentPage = [[[dict objectForKey:@"data"] objectForKey:@"page"] integerValue];
  213. self.youpaipcurrentPage = currentPage;
  214. for (YOUPAIZYVideoModel *model in modelArray) {
  215. [self.youpaipmp4UrlArray addObject:[NSURL URLWithString:model.youpaipfile_url]];
  216. }
  217. self.youpaipzFplayer.assetURLs = self.youpaipmp4UrlArray;
  218. [self.youpaiptableView reloadData];
  219. NSIndexPath* indexPath = [NSIndexPath indexPathForRow:count inSection:0];
  220. [self.youpaiptableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionTop animated:YES];
  221. [self youpaifplayTheVideoAtIndexPath:indexPath];
  222. if (self.youpaipisLeavePage) {
  223. [self.youpaipzFplayer.currentPlayerManager pause];
  224. }
  225. // __weak typeof(self) weakSelf = self;
  226. // [self.zFplayer zf_filterShouldPlayCellWhileScrolled:^(NSIndexPath *indexPath) {
  227. // [weakSelf youpaifplayTheVideoAtIndexPath:indexPath];
  228. // }];
  229. if (currentPage>=self.youpaiptotalPage) {
  230. [self.youpaiptableView.mj_footer endRefreshingWithNoMoreData];
  231. self.youpaiptableView.mj_footer.hidden = YES;
  232. }
  233. [self.youpaiptableView.mj_header endRefreshing];
  234. }
  235. [self.youpaiptableView.mj_footer endRefreshing];
  236. } failure:^(NSError *error) {
  237. [self.youpaiptableView.mj_footer endRefreshing];
  238. }];
  239. }
  240. -(void)youpaifinitTableView
  241. {
  242. _youpaiptableView = [[UITableView alloc] initWithFrame:CGRectMake(0,0,KScreenWidth, KScreenHeight) style:UITableViewStylePlain];
  243. NSLog(@"%lf",_youpaiptableView.frame.size.height);
  244. _youpaiptableView.pagingEnabled = YES;
  245. [_youpaiptableView registerClass:[YOUPAIEyeCatchingWaiterCell class] forCellReuseIdentifier:@"YOUPAIEyeCatchingWaiterCell"];
  246. _youpaiptableView.backgroundColor = [UIColor blackColor];
  247. _youpaiptableView.delegate = self;
  248. _youpaiptableView.dataSource = self;
  249. _youpaiptableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  250. _youpaiptableView.showsVerticalScrollIndicator = NO;
  251. _youpaiptableView.scrollsToTop = NO;
  252. if (@available(iOS 11.0, *)) {
  253. _youpaiptableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
  254. } else {
  255. self.automaticallyAdjustsScrollViewInsets = NO;
  256. }
  257. _youpaiptableView.estimatedRowHeight = 0;
  258. _youpaiptableView.estimatedSectionFooterHeight = 0;
  259. _youpaiptableView.estimatedSectionHeaderHeight = 0;
  260. _youpaiptableView.rowHeight = KScreenHeight;
  261. _youpaiptableView.scrollsToTop = NO;
  262. _youpaiptableView.mj_header = [LCRefreshDotGiftHeader headerWithRefreshingTarget:self refreshingAction:@selector(youpaifloadNewData)];
  263. if (@available(iOS 15.0, *)) {
  264. _youpaiptableView.sectionHeaderTopPadding = 0;
  265. }
  266. NSLog(@"%lf",_youpaiptableView.frame.size.height);
  267. [self.view addSubview:_youpaiptableView];
  268. }
  269. /// play the video
  270. - (void)youpaifplayTheVideoAtIndexPath:(NSIndexPath *)indexPath {
  271. [self.youpaipzFplayer playTheIndexPath:indexPath];
  272. [self.youpaipcontrolView youpaifresetControlView];
  273. YOUPAIZYVideoModel *model = self.youpaipvideoDataArray[indexPath.row];
  274. [self youpaiftrendsBrowser:model];
  275. }
  276. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
  277. // self.tableView.mj_footer.hidden = self.videoDataArray.count>0?NO:YES;
  278. return self.youpaipvideoDataArray.count;
  279. }
  280. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
  281. YOUPAIEyeCatchingWaiterCell * cell = [tableView dequeueReusableCellWithIdentifier:@"YOUPAIEyeCatchingWaiterCell" forIndexPath:indexPath];
  282. self.youpaipindexPath = indexPath;
  283. cell.backgroundColor = [UIColor blackColor];
  284. YOUPAIZYVideoModel *model = self.youpaipvideoDataArray[indexPath.row];
  285. cell.model = model;
  286. cell.delegate = self;
  287. cell.hidesBottomBar = self.hidesBottomBarWhenPushed;
  288. return cell;
  289. }
  290. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  291. [self youpaifplayTheVideoAtIndexPath:indexPath];
  292. }
  293. #pragma mark - UIScrollViewDelegate 列表播放必须实现
  294. - (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
  295. [scrollView zf_scrollViewDidEndDecelerating];
  296. }
  297. - (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate {
  298. [scrollView zf_scrollViewDidEndDraggingWillDecelerate:decelerate];
  299. }
  300. - (void)scrollViewDidScrollToTop:(UIScrollView *)scrollView {
  301. [scrollView zf_scrollViewDidScrollToTop];
  302. }
  303. - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
  304. [scrollView zf_scrollViewDidScroll];
  305. }
  306. - (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView {
  307. [scrollView zf_scrollViewWillBeginDragging];
  308. }
  309. #pragma mark --- 懒加载
  310. - (YOUPAIZFDouYinControlView *)youpaipcontrolView {
  311. if (!_youpaipcontrolView) {
  312. _youpaipcontrolView = [YOUPAIZFDouYinControlView new];
  313. }
  314. return _youpaipcontrolView;
  315. }
  316. - (ZFPlayerController *)youpaipzFplayer{
  317. if (_youpaipzFplayer == nil) {
  318. ZFAVPlayerManager *playerManager = [[ZFAVPlayerManager alloc] init];
  319. _youpaipzFplayer = [ZFPlayerController playerWithScrollView:self.youpaiptableView playerManager:playerManager containerViewTag:100];
  320. _youpaipzFplayer.disableGestureTypes = ZFPlayerDisableGestureTypesDoubleTap | ZFPlayerDisableGestureTypesPan | ZFPlayerDisableGestureTypesPinch;
  321. _youpaipzFplayer.allowOrentitaionRotation = NO;
  322. _youpaipzFplayer.WWANAutoPlay = YES;
  323. _youpaipzFplayer.playerDisapperaPercent = 1.0;
  324. _youpaipzFplayer.controlView = self.youpaipcontrolView;
  325. __weak typeof(self) weakSelf = self;
  326. _youpaipzFplayer.playerDidToEnd = ^(id _Nonnull asset) { // 播放结束后重新播放
  327. [weakSelf.youpaipzFplayer.currentPlayerManager replay];
  328. };
  329. _youpaipzFplayer.presentationSizeChanged = ^(id<ZFPlayerMediaPlayback> _Nonnull asset, CGSize size) { // 视频画面显示的模式
  330. NSInteger index = [weakSelf.youpaipmp4UrlArray indexOfObject:asset.assetURL];
  331. if (weakSelf.youpaipvideoDataArray.count >= index) {
  332. YOUPAIZYVideoModel *model = weakSelf.youpaipvideoDataArray[index];
  333. if (model.youpaipmode == 0) {
  334. if (size.width >= size.height) {
  335. model.youpaipmode = UIViewContentModeScaleAspectFit;
  336. } else {
  337. model.youpaipmode = UIViewContentModeScaleAspectFill;
  338. }
  339. }
  340. if (model.youpaipmode == UIViewContentModeScaleAspectFit) {
  341. weakSelf.youpaipzFplayer.currentPlayerManager.scalingMode = ZFPlayerScalingModeAspectFit;
  342. }else{
  343. weakSelf.youpaipzFplayer.currentPlayerManager.scalingMode = ZFPlayerScalingModeAspectFill;
  344. }
  345. }
  346. };
  347. [_youpaipzFplayer setPlayerPrepareToPlay:^(id<ZFPlayerMediaPlayback> _Nonnull asset, NSURL * _Nonnull assetURL) {
  348. NSInteger index = [weakSelf.youpaipmp4UrlArray indexOfObject:asset.assetURL];
  349. if (weakSelf.youpaipvideoDataArray.count >= index) {
  350. YOUPAIZYVideoModel *model = weakSelf.youpaipvideoDataArray[index];
  351. if (model.youpaipmode == UIViewContentModeScaleAspectFit) {
  352. weakSelf.youpaipzFplayer.currentPlayerManager.scalingMode = ZFPlayerScalingModeAspectFit;
  353. }else{
  354. weakSelf.youpaipzFplayer.currentPlayerManager.scalingMode = ZFPlayerScalingModeAspectFill;
  355. }
  356. }
  357. }];
  358. /// 停止的时候找出最合适的播放
  359. _youpaipzFplayer.zf_scrollViewDidEndScrollingCallback = ^(NSIndexPath * _Nonnull indexPath) {
  360. if (weakSelf.youpaipzFplayer.playingIndexPath) return;
  361. /// 加载下一页数据
  362. weakSelf.youpaipzFplayer.assetURLs = weakSelf.youpaipmp4UrlArray;
  363. [weakSelf.youpaiptableView reloadData];
  364. [weakSelf youpaifplayTheVideoAtIndexPath:indexPath];
  365. };
  366. }
  367. return _youpaipzFplayer;
  368. }
  369. #pragma EyeCatchingWaiterCellDelegate //cell的代理
  370. - (void)youpaifclickAvatar:(YOUPAIZYVideoModel*)model;//点击了头像
  371. {
  372. //LCUserShowVC* userShow = [[LCUserShowVC alloc]init];
  373. YOUPAILZUserShowVC *userShow = [[YOUPAILZUserShowVC alloc] init];
  374. userShow.youpaipuserId = model.youpaipuser_id;
  375. // userShow.videoModel = model;
  376. // userShow.delegate = self;
  377. [self.navigationController pushViewController:userShow animated:YES];
  378. }
  379. -(void)youpaifclickNikname:(YOUPAIZYVideoModel *)model
  380. {
  381. YOUPAILZUserShowVC *userShow = [[YOUPAILZUserShowVC alloc] init];
  382. userShow.youpaipuserId = model.youpaipuser_id;
  383. // userShow.videoModel = model;
  384. // userShow.delegate = self;
  385. [self.navigationController pushViewController:userShow animated:YES];
  386. }
  387. - (void)youpaifclickAttention:(YOUPAIZYVideoModel*)model;//点击了关注
  388. {
  389. if (model.youpaipis_follow == 0) {//+关注
  390. [LCCommonHttp followUserId:model.youpaipuser_id];
  391. model.youpaipis_follow = 1;
  392. [self.youpaiptableView reloadData];
  393. }else{
  394. [LCCommonHttp followUserId:model.youpaipuser_id];
  395. model.youpaipis_follow = 0;
  396. [self.youpaiptableView reloadData];
  397. }
  398. }
  399. - (void)youpaifclickSupport:(YOUPAIZYVideoModel*)model;//点击了点赞
  400. {
  401. [self.youpaiptableView reloadData];
  402. }
  403. -(void)youpaifclickImVideo:(YOUPAIZYVideoModel *)model;//点击了视频
  404. {
  405. if ([YOUPAILZChatRoomManager shareManager].chatroomWindow != nil && [YOUPAILZChatRoomManager shareManager].chatroomWindow.hidden == NO) {
  406. [ZCHUDHelper showTitle:@"你正在房间中,暂不可拨打视频"];
  407. return;
  408. }
  409. [UCAuthorityManager cameraAuthority:^{
  410. [LCHttpHelper requestWithURLString:CallChatType parameters:@{@"to_uid":model.youpaipuser_id,@"type":@"0"} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  411. NSDictionary* dict = (NSDictionary*)responseObject;
  412. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  413. if (code==0) {//成功
  414. YOUPAILCVideoChatModel* videoModel = [YOUPAILCVideoChatModel mj_objectWithKeyValues:[dict objectForKey:@"data"]];
  415. [[YOUPAILZChatRoomManager shareManager] youpaifcloseChatRoom];
  416. [[NSNotificationCenter defaultCenter] postNotificationName:@"MeCallVideo" object:nil userInfo:nil];
  417. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0f * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  418. YOUPAILCVideoRequestVC* chatRequest = [[YOUPAILCVideoRequestVC alloc]init];
  419. chatRequest.youpaipvideoModel = videoModel;
  420. //modify by leo fix bug ios13
  421. ZCBaseNavigationVC *nav = [[ZCBaseNavigationVC alloc]initWithRootViewController:chatRequest];
  422. chatRequest.view.backgroundColor = HexColorFromRGBA(0x000000, 0.55);
  423. chatRequest.definesPresentationContext = YES;
  424. nav.modalPresentationStyle = UIModalPresentationOverCurrentContext;
  425. [self.navigationController presentViewController:nav animated:YES completion:^{
  426. // chatRequest.view.backgroundColor = HexColorFromRGBA(0x000000, 0.55);
  427. }];
  428. });
  429. }
  430. } failure:^(NSError *error) {
  431. }];
  432. } denied:^{
  433. dispatch_async(dispatch_get_main_queue(), ^{
  434. UIAlertController *systemAlert = [UIAlertController alertControllerWithTitle:@"请在iphone的“设置-隐私-相机”选项中,允许APP访问您的相机。" message:nil preferredStyle:UIAlertControllerStyleAlert];
  435. UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"现在去设置" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action){
  436. if ([[UIDevice currentDevice].systemVersion floatValue] < 10.0)
  437. {
  438. [[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
  439. }
  440. else
  441. {
  442. // 去系统设置页面
  443. if (@available(iOS 10.0, *)) {
  444. [[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString] options:@{} completionHandler:nil];
  445. } else {
  446. // Fallback on earlier versions
  447. }
  448. }
  449. }];
  450. UIAlertAction *action = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:nil];
  451. [systemAlert addAction:cancelAction];
  452. [systemAlert addAction:action];
  453. [self presentViewController: systemAlert animated: YES completion: nil];
  454. });
  455. }];
  456. }
  457. //累加视频动态浏览量
  458. -(void)youpaiftrendsBrowser:(YOUPAIZYVideoModel *)model{
  459. [LCHttpHelper requestWithURLString:TrendsBrowser parameters:@{@"vt_id":model.youpaipvideoId} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  460. NSDictionary* dict = (NSDictionary*)responseObject;
  461. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  462. if (code==0) {//成功
  463. NSString *view_count = [NSString stringWithFormat:@"%@",[[dict objectForKey:@"data"] objectForKey:@"view_count"]];
  464. model.youpaipview_count = [view_count integerValue];
  465. [self.youpaiptableView reloadData];
  466. }
  467. } failure:^(NSError *error) {
  468. }];
  469. }
  470. // 点击了礼物
  471. - (void)youpaifclickGift:(YOUPAIZYVideoModel *)model{
  472. YOUPAILZCommonGiftView *view = [YOUPAILZCommonGiftView new];
  473. view.isTouchDismiss = YES;
  474. view.youpaipisAnchor = NO;
  475. [view setJumToWalletBlock1:^{
  476. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5f * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  477. [[NSNotificationCenter defaultCenter] postNotificationName:@"InsufficientBalanceNotice" object:nil userInfo:nil];
  478. YOUPAIXRWalletVC *coinRecharge = [[YOUPAIXRWalletVC alloc]init];
  479. [self.navigationController pushViewController:coinRecharge animated:YES];
  480. });
  481. }];
  482. [view setYoupaiplzgiftblock:^(YOUPAILCGiftModel * _Nonnull giftModel, NSInteger count,NSString *categoryID) {
  483. [LCHttpHelper requestWithURLString:SendGift_New parameters:@{@"type":@(6),@"to_uid":model.youpaipuser_id,@"gift_id":giftModel.youpaipid,@"num":@(count),@"gift_type_id":categoryID} needToken:YES type:(HttpRequestTypePost) success:^(id responseObject) {
  484. NSDictionary* dict = (NSDictionary*)responseObject;
  485. NSInteger code = [[dict objectForKey:@"code"] integerValue];
  486. if (code==0) {//成功
  487. [ZCHUDHelper showTitle:@"礼物赠送成功"];
  488. }
  489. } failure:^(NSError *error) {
  490. }];
  491. }];
  492. [self TFPresentVC:view completion:^{
  493. }];
  494. }
  495. //#pragma mark -- LZUserShowVCDelegate
  496. //-(void)youpaifclickUserShowVCAttention:(YOUPAIZYVideoModel *)model
  497. //{
  498. // [self.tableView reloadData];
  499. //}
  500. @end