|
@@ -9,12 +9,24 @@
|
|
|
#import "MineIntroduceCell.h"
|
|
|
#import "MineVideoCell.h"
|
|
|
#import "MineFansGroupCell.h"
|
|
|
+#import "StyleVideoModel.h"
|
|
|
+#import "WMPlayer.h"
|
|
|
|
|
|
+@interface MinePageMienBodyView ()<UITableViewDelegate,UITableViewDataSource,WMPlayerDelegate>
|
|
|
+{
|
|
|
+ WMPlayer *_wmPlayer;
|
|
|
+ CGRect _playerFrame;
|
|
|
+}
|
|
|
+@property (nonatomic, strong) UIView *bgView;
|
|
|
|
|
|
-@interface MinePageMienBodyView ()<UITableViewDelegate,UITableViewDataSource>
|
|
|
+@property (nonatomic, assign) BOOL isRatation;
|
|
|
|
|
|
@property (nonatomic, strong) NSMutableArray *fansGroupArray;
|
|
|
|
|
|
+@property (nonatomic, strong) NSString *content;
|
|
|
+
|
|
|
+@property (nonatomic, strong) NSMutableArray *videoArray;
|
|
|
+
|
|
|
@end
|
|
|
|
|
|
@implementation MinePageMienBodyView
|
|
@@ -55,7 +67,31 @@
|
|
|
}
|
|
|
|
|
|
- (void)requestData {
|
|
|
-
|
|
|
+ [KSNetworkingManager queryTeacherStyleRequest:KS_GET success:^(NSDictionary * _Nonnull dic) {
|
|
|
+ [self endRefresh];
|
|
|
+ if ([dic integerValueForKey:@"code"] == 200 && [dic boolValueForKey:@"status"]) {
|
|
|
+ NSDictionary *result = [dic dictionaryValueForKey:@"data"];
|
|
|
+ self.content = [result stringValueForKey:@"introduction"];
|
|
|
+ NSArray *videoList = [result arrayValueForKey:@"styleVideo"];
|
|
|
+ [self.videoArray removeAllObjects];
|
|
|
+ for (NSDictionary *parm in videoList) {
|
|
|
+ StyleVideoModel *model = [[StyleVideoModel alloc] initWithDictionary:parm];
|
|
|
+ [self.videoArray addObject:model];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ [self MBPShow:MESSAGEKEY];
|
|
|
+ }
|
|
|
+ [self.tableView reloadData];
|
|
|
+ } faliure:^(NSError * _Nonnull error) {
|
|
|
+ [self endRefresh];
|
|
|
+ }];
|
|
|
+}
|
|
|
+
|
|
|
+- (void)endRefresh {
|
|
|
+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
|
|
+ [self.tableView.mj_header endRefreshing];
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
- (void)beginRefreshImmediately {
|
|
@@ -101,10 +137,20 @@
|
|
|
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
|
|
|
if (indexPath.section == 0) {
|
|
|
MineIntroduceCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MineIntroduceCell"];
|
|
|
+ [cell configIntroduce:self.content];
|
|
|
return cell;
|
|
|
}
|
|
|
else if (indexPath.section == 1) {
|
|
|
MineVideoCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MineVideoCell"];
|
|
|
+ [cell configWithSource:self.videoArray];
|
|
|
+ MJWeakSelf;
|
|
|
+ [cell opreationCallback:^(UIView * _Nullable containerView) {
|
|
|
+ NSInteger index = containerView.tag - 1000;
|
|
|
+ if (weakSelf.videoArray.count > index) {
|
|
|
+ StyleVideoModel *model = weakSelf.videoArray[index];
|
|
|
+ [weakSelf playVideoWithUrl:model.videoUrl];
|
|
|
+ }
|
|
|
+ }];
|
|
|
return cell;
|
|
|
}
|
|
|
else {
|
|
@@ -113,6 +159,8 @@
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
|
|
|
if (section == 2) {
|
|
|
return [UIView new];
|
|
@@ -134,6 +182,65 @@
|
|
|
return CGFLOAT_MIN;
|
|
|
}
|
|
|
|
|
|
+- (NSMutableArray *)videoArray {
|
|
|
+ if (!_videoArray) {
|
|
|
+ _videoArray = [NSMutableArray array];
|
|
|
+ }
|
|
|
+ return _videoArray;
|
|
|
+}
|
|
|
+
|
|
|
+#pragma mark ------ WMPlayer
|
|
|
+- (void)playVideoWithUrl:(NSString *)fileUrl {
|
|
|
+ fileUrl = [fileUrl stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]];
|
|
|
+ _playerFrame = CGRectMake(0, iPhoneXSafeTopMargin, kScreenWidth, kScreenHeight - iPhoneXSafeTopMargin - iPhoneXSafeBottomMargin);
|
|
|
+ _wmPlayer = [[WMPlayer alloc] initWithFrame:_playerFrame];
|
|
|
+ WMPlayerModel *playModel = [[WMPlayerModel alloc] init];
|
|
|
+ playModel.videoURL = [NSURL URLWithString:fileUrl];
|
|
|
+ _wmPlayer.playerModel = playModel;
|
|
|
+ _wmPlayer.delegate = self;
|
|
|
+ _bgView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight)];
|
|
|
+ _bgView.backgroundColor = [UIColor blackColor];
|
|
|
+ [[UIApplication sharedApplication].keyWindow addSubview:_bgView];
|
|
|
+ [[UIApplication sharedApplication].keyWindow addSubview:_wmPlayer];
|
|
|
+ [[UIApplication sharedApplication].keyWindow bringSubviewToFront:_wmPlayer];
|
|
|
+
|
|
|
+ [_wmPlayer play];
|
|
|
+}
|
|
|
+
|
|
|
+- (void)wmplayer:(WMPlayer *)wmplayer clickedCloseButton:(UIButton *)backBtn {
|
|
|
+ [wmplayer removePlayer];
|
|
|
+ [_bgView removeFromSuperview];
|
|
|
+ [self.naviController setNeedsStatusBarAppearanceUpdate];
|
|
|
+}
|
|
|
+
|
|
|
+- (void)wmplayer:(WMPlayer *)wmplayer clickedFullScreenButton:(UIButton *)fullScreenBtn {
|
|
|
+ self.isRatation = !self.isRatation;
|
|
|
+
|
|
|
+ if (self.isRatation) {
|
|
|
+ [wmplayer removeFromSuperview];
|
|
|
+ [UIView animateWithDuration:1.0f animations:^{
|
|
|
+ wmplayer.transform = CGAffineTransformMakeRotation(M_PI_2);
|
|
|
+
|
|
|
+ } completion:^(BOOL finished) {
|
|
|
+ wmplayer.frame = CGRectMake(0, iPhoneXSafeTopMargin, kScreenWidth, kScreenHeight - iPhoneXSafeTopMargin - iPhoneXSafeBottomMargin);
|
|
|
+ [[UIApplication sharedApplication].keyWindow addSubview:wmplayer];
|
|
|
+ [[UIApplication sharedApplication].keyWindow bringSubviewToFront:wmplayer];
|
|
|
+ }];
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ [wmplayer removeFromSuperview];
|
|
|
+
|
|
|
+ [UIView animateWithDuration:1.0f animations:^{
|
|
|
+ // 复原
|
|
|
+ wmplayer.transform = CGAffineTransformIdentity;
|
|
|
+
|
|
|
+ } completion:^(BOOL finished) {
|
|
|
+ wmplayer.frame = CGRectMake(0, iPhoneXSafeTopMargin, kScreenWidth, kScreenHeight - iPhoneXSafeTopMargin - iPhoneXSafeBottomMargin);
|
|
|
+ [[UIApplication sharedApplication].keyWindow addSubview:wmplayer];
|
|
|
+ [[UIApplication sharedApplication].keyWindow bringSubviewToFront:wmplayer];
|
|
|
+ }];
|
|
|
+ }
|
|
|
+}
|
|
|
/*
|
|
|
// Only override drawRect: if you perform custom drawing.
|
|
|
// An empty implementation adversely affects performance during animation.
|